This question already has an answer here:
- How to delete many 0 byte files in linux? 10 answers
How do I delete a certain file in linux if its size is 0. I want to execute this in an crontab without any extra script.
l filename.file | grep 5th-tab | not eq 0 | rm
Something like this?
you would want to use find:
To search and delete empty files in the current directory and subdirectories:
-type f
is necessary because also directories are marked to be of size zero.The dot
.
(current directory) is the starting search directory. If you have GNU find (e.g. not Mac OS), you can omit it in this case:From GNU
find
documentation: