In order to list empty files I do
find . -name "*.txt" | xargs wc -l | awk -F" " '{if ($1==0) {print $2} }'
or simply
wc -l *.txt | awk -F" " '{if ($1==0) {print $2} }'
It works but it is a bit slow as wc -l
counts the number of newline characters in each file while this is not necessary. A process that excludes files as soon as they find a single newline character would be much faster.
How can one list empty files in a performant way?
find . -name '*.txt' -size 0
Print files which match *.txt
and are of size zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With