Delete Empty Directories

Refer: https://unix.stackexchange.com/questions/46322/how-can-i-recursively-delete-empty-directories-in-my-home-directory

The find command is the primary tool for recursive file system operations. Use the -type d expression to tell find you're interested in finding directories only (and not plain files).
The GNU version of find supports the -empty test, so

Print all empty directories below your current directory.
find . -type d -empty -print

After you've verified that this is selecting the correct directories, use -delete to delete all matches:
find . -type d -empty -delete

Leave a Reply