Home > Uncategorized > Find empty folders on Linux

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 {} \;

q.v. find manpage

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.