====== Linux - Find - Find Empty Directories ======
find ./ -type d -empty
This command will find all empty directories in the current directory with sub-directories and then print the full pathname for each empty directory to the screen.
* **./** means start searching from the current directory. If you want to find files from another directory then replace the ./ with the path to needed directory. For example, to search everything under the system log directory you need to replace ./ with /var/log.
* **-type d** flag is specifies to find only directories.
* **-empty** flag is specifies to find empty directories.
----
===== Find and then delete all empty directories =====
To find and then delete all empty directories, use:
find ./ -depth -type d -empty -exec rmdir {} \;
or
find ./ -type d -empty -delete
**NOTE:** The **-delete** option is the best choice when it is supported by the find you are using.