Question

The manpage only gives these options:

      --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

How would I pipe a find or ls to recursively delete all empty directories in a file tree?

Was it helpful?

Solution

find . -type d -empty -delete

Like all destructive commands, print and sanity check the targets (omit the -delete) before executing the full command.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top