0

I would like to clean up some folders. So I want to delete all folders which are empty or only contain other folders...

First I tried

find . -type d -delete

but this lists the subfolders after the parents, so I would have to execute it multiple times.

So I tried using tac and pipes

find . -type d | tac | xargs rmdir

This one fails on whitespaces, etc, so I need a masking - now I am stuck...

Jaster
  • 101
  • 2

1 Answers1

1
find . -type d -depth -exec rmdir {} +

should work if you have a halfway recent find(1) - note that execplus was added in 1989 ;-)

Note that there was a hint that there may be non-standard find implementations that emit a warning when -depth was not specified as the first primary.

schily
  • 19,173