Bash: find and remove empty files and directories

From lxadm | Linux administration tips, tutorials, HOWTOs and articles
Jump to: navigation, search

To find and remove empty files (0-byte files), you can use:

find /some/directory -type f -empty -delete


To find and remove empty directories, you can use:

find /some/directory -type d -empty -delete


To find and remove both empty files and directories, you can use:

find /some/directory -empty -delete