How to search for files by size and extension

command linefindsearch

I want to delete all empty files with a particular extension from a directory and all its subdirectories.

Best Answer

You can try the following, to confirm upon deleting each file first:

$ find /path/to/dir -type f -name "*.txt" -empty -ok rm {} \;

or if you feel more confident:

$ find /path/to/dir -type f -name "*.txt" -empty -exec rm {} \;
Related Question