You have loads of empty directories to delete in Linux? There is a command for that!
How to list empty directories in Linux?
With the command find . -type d -empty -print .. run it in the top level directory you’re interested in cleaning
Go to the directory in which you want to clean empty directories, and start with the following command that allows to list them :
find . -type d -empty -print
You’ll get an output such as:
root@hurricane:~# find . -type d -empty -print
./.config/htop
./test
./.cache/composer/files/phpoption/phpoption
./.cache/composer/files/ovh/ovh
./.cache/composer/files/phpdocumentor/phpdocumentor
./.cache/composer/files/phpdocumentor/reflection
./.cache/composer/files/phpdocumentor/fileset
./.cache/composer/files/phpdocumentor/graphviz
Now if that is fine with you , the same command with a slight variation:
find . -type d -empty -delete
And there you go you’ve recusirvely deleted empty folders
Tested on Debian Stretch (9)
This post is also available in fr_FR.