- # 文件夹结构
- [seesea@bathome test]$ ls A/
- atimetool_1.9.6 atimetool_1.9.7 atimetool_1.9.8
- [seesea@bathome test]$ ls A/*/*
- A/atimetool_1.9.6:
- atimetool_1.9.xxxx.deb
- atimetool_1.9.6.deb
-
- A/atimetool_1.9.7:
- atimetool_1.9.xxxx.deb
- atimetool_1.9.7.deb
- atimetool_1.9.6.deb
-
- A/atimetool_1.9.8:
- atimetool_1.9.6.deb
- # 生成重复列表
- [seesea@bathome test]$ for f in A/*/*.deb; do echo ${f##*/}; done | sort | uniq -c | sort -r
- 3 atimetool_1.9.6.deb
- 2 atimetool_1.9.xxxx.deb
- 1 atimetool_1.9.7.deb
- # 生成重复列表->文件
- [seesea@bathome test]$ for f in A/*/*.deb; do echo ${f##*/}; done | sort | uniq -c | sort -r > result.txt
- # 生成操作菜单,根据选择进行操作
- [seesea@bathome test]$ select menu in $(awk '{print $2}' result.txt) "QUIT";do if [ "$menu" = "QUIT" ]; then break; fi; rm -rf A/*/$menu; done
- 1) atimetool_1.9.6.deb
- 2) atimetool_1.9.xxxx.deb
- 3) atimetool_1.9.7.deb
- 4) QUIT
- #? 1
- #? 2
- #? 3
- #? 4
- # 删除完文件的结果
- [seesea@bathome test]$ ls A/atimetool_1.9.*
- A/atimetool_1.9.6:
-
- A/atimetool_1.9.7:
-
- A/atimetool_1.9.8:
复制代码
|