可以递归使用rmdir吗?

时间:2013-06-24 18:12:50

标签: unix pipe rmdir

该联机帮助页仅提供以下选项:

      --ignore-fail-on-non-empty
                  ignore each failure that is solely because a directory
                  is non-empty
  -p, --parents   Remove DIRECTORY and its ancestors.  E.g., `rmdir -p a/b/c' is
                  similar to `rmdir a/b/c a/b a'.
  -v, --verbose   output a diagnostic for every directory processed
      --help     display this help and exit
      --version  output version information and exit

如何管道findls以递归方式删除文件树中的所有空目录?

1 个答案:

答案 0 :(得分:3)

find . -type d -empty -delete

与所有破坏性命令一样,print和sanity在执行完整命令之前检查目标(省略-delete)。