[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. # 文件夹结构
  2. [seesea@bathome test]$ ls A/
  3. atimetool_1.9.6  atimetool_1.9.7  atimetool_1.9.8
  4. [seesea@bathome test]$ ls A/*/*
  5. A/atimetool_1.9.6:
  6. atimetool_1.9.xxxx.deb
  7. atimetool_1.9.6.deb
  8. A/atimetool_1.9.7:
  9. atimetool_1.9.xxxx.deb
  10. atimetool_1.9.7.deb
  11. atimetool_1.9.6.deb
  12. A/atimetool_1.9.8:
  13. atimetool_1.9.6.deb
  14. # 生成重复列表
  15. [seesea@bathome test]$ for f in A/*/*.deb; do echo ${f##*/}; done | sort | uniq -c | sort -r
  16.       3 atimetool_1.9.6.deb
  17.       2 atimetool_1.9.xxxx.deb
  18.       1 atimetool_1.9.7.deb
  19. # 生成重复列表->文件
  20. [seesea@bathome test]$ for f in A/*/*.deb; do echo ${f##*/}; done | sort | uniq -c | sort -r > result.txt
  21. # 生成操作菜单,根据选择进行操作
  22. [seesea@bathome test]$ select menu in $(awk '{print $2}' result.txt) "QUIT";do if [ "$menu" = "QUIT" ]; then break; fi; rm -rf A/*/$menu; done
  23. 1) atimetool_1.9.6.deb
  24. 2) atimetool_1.9.xxxx.deb
  25. 3) atimetool_1.9.7.deb
  26. 4) QUIT
  27. #? 1
  28. #? 2
  29. #? 3
  30. #? 4
  31. # 删除完文件的结果
  32. [seesea@bathome test]$ ls A/atimetool_1.9.*
  33. A/atimetool_1.9.6:
  34. A/atimetool_1.9.7:
  35. A/atimetool_1.9.8:
复制代码

TOP

返回列表