Linux – Find empty directories and/or remove

By | August 24, 2015


I needed this command and had to look around to try and find it. There is often a need on Linux to be able to find an empty directory, and maybe to remove it as well.

Find empty directories and/or remove

Find empty directories in the current directory using find -empty

find . -type d -empty

You can then use the following command to remove all empty directories under the current directory.

find . -type d -empty -exec rmdir {} \;

Be careful when you do this to always run the first command (without the -exec) first so you know what you are about to remove !!

Are you looking for an web agency in Tokyo? Tokyo website design by Webguru Come talk to us in Shibuya A great collection of cheap responsive web designs on this site that can be hosted on Windows or Linux servers and minimize the web development effort
Check out -  How to extract emails from a PST file using Bash on Centos

Leave a Reply