Find empty folders on Linux

      No Comments on Find empty folders on Linux

Well, there is no native command (at least, afaik), but you can use find to easily identify empty folders (which maybe helpful for maintenance, etc.):

# find /path -type d -empty

Find empty folder and list

# find /path -type d -empty -exec ls -ld {} \;

Find empty folder and save as temporary file

# find /path -type d -empty -exec ls -ld >> /tmp/savefiles.txt {} \;

Find empty folder and delete

# find /path -type d -empty -exec rmdir {} \;

See also find manpage

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.