
我想清理一些資料夾。所以我想刪除所有空資料夾或僅包含其他資料夾...
首先我嘗試過
find . -type d -delete
但這列出了父資料夾之後的子資料夾,因此我必須多次執行它。
所以我嘗試使用 tac 和管道
find . -type d | tac | xargs rmdir
這個在空格等方面失敗了,所以我需要一個掩碼 - 現在我陷入困境...
答案1
find . -type d -depth -exec rmdir {} +
如果您最近有一半的 find(1) 應該可以工作 - 請注意 execplus 是在 1989 年添加的;-)
請注意,有一個提示,表明可能有非標準查找實現在-depth
未指定為第一個時發出警告primary
。