Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Delete empty directories (UNIX) (See related posts)

// Shell command to delete empty directories. May have to run several times to get everything.

find . -type d -empty | xargs rmdir -

Comments on this post

ghbol posts on Feb 14, 2007 at 04:01
// To delete all empty directories in one go, add the -depth option to the find comment:

find . -type d -empty -depth | xargs rmdir -
ghbol posts on Feb 14, 2007 at 04:19
// correction...

find dir2 -depth -empty -type d -exec rmdir {} \;

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts