0

I am used to listing and sorting the size of files as follows:

$ for entry in $(ls); do du -s "$entry"; done | sort -n

However, how does one delete all files of 0 bytes?

My terrible attempt would be to try an if conditional, but I don't know how to check the size. I would then pipe all results and remove these?

$ for entry in $(ls); if du -s "$entry" == 0 | rm "$entry"

1 Answers1

4

You could use find:

find . -maxdepth 1 -type f -size 0 -delete
thiagowfx
  • 1,249