I have a folder that contains hundreds of thousands of small .txt files of size 4kb. Some of them are totally empty while others are not. However, they all show the same size 4kb since this is the minimum block size configured. Is there a way to massively delete the empty ones but keep the non empty? Doing an
rsync --remove-sent-files -rv --min-size=4kb
removes everything.
Thank you
I think I found a partial answer. If we suppose that a txt file with an empty content has at least one hidden character, then someone can find all files with size under a specific number of bytes and delete these. If for example we would like to delete all files of size 1 byte we can issue:
The truly empty files will show 0 bytes, when looked at with
ls -l
.You can remove them with
find
(readman find
https://manpages.ubuntu.com/manpages/cosmic/en/man1/find.1.html):