Skip to main content
Expanded with alternative command
Source Link
skeetastax
  • 251
  • 2
  • 7

Combining Gareth's and G-Man's posts:

find . -depth -type d -empty -execdir rmdir {} +

Edit: But that gave a security error because of 'C' in my PATH var...so instead:

$find . -depth -type d -empty | while read dir; do (rmdir -v $dir); done

I don't use xargs because it appears to have an input line limit (of about 1024 lines, I think?), whereas

 while read x; do (command $x); done

just keeps on going for as long as it has input. Leave out the '-v' verbose flag if you don't want to see the results and/or want it to run faster.

Combining Gareth's and G-Man's posts:

find . -depth -type d -empty -execdir rmdir {} +

Combining Gareth's and G-Man's posts:

find . -depth -type d -empty -execdir rmdir {} +

Edit: But that gave a security error because of 'C' in my PATH var...so instead:

$find . -depth -type d -empty | while read dir; do (rmdir -v $dir); done

I don't use xargs because it appears to have an input line limit (of about 1024 lines, I think?), whereas

 while read x; do (command $x); done

just keeps on going for as long as it has input. Leave out the '-v' verbose flag if you don't want to see the results and/or want it to run faster.

Source Link
skeetastax
  • 251
  • 2
  • 7

Combining Gareth's and G-Man's posts:

find . -depth -type d -empty -execdir rmdir {} +