
如何刪除run-*.achilles
Linux 下所有子目錄中的所有目錄?
我嘗試過find /path -name run-*.achilles -type f -delete
,但沒有成功。
答案1
這裡有幾個問題:
- 您應該引用
*
以防止 shell 通配符。 -type f
告訴find
你想要文件。find -delete
不會刪除非空目錄。看到這個問題。從那裡的答案之一調整解決方案:find /path -path '*/run-*.achilles/*' -delete find /path -type d -name 'run-*.achilles' -empty -delete
它並不完美,第一行會匹配.../run-a/b.achilles/...
。我認為。這個指令應該要匹配得更好:
find /path -type d -name 'run-*.achilles' -exec rm -rf {} +
它使用rm -rf
,所以要小心。