Using the find command, it is easy to recursively delete all empty directories. Which empty directories are safe to delete, and which ones are not?
1 Answer
You can recursively delete directories in which you put your data (like Documents
, Videos
, Images
, Downloads
, etc.), the others into your home directory (e.g. .cache
, .gnome
, , .ssh
), your root, its sub-folders, etc., shouldn't be removed in this way!
A useful and quite safe way to do this is using the rmdir
command (with find
):
find . -empty -type d -exec rmdir {} +
It starts in the current working directory.
/
? Because if so, don't do that.