How can I find all zero-byte files in a directory and even in subdirectories?
I have done this:
#!/bin/bash
lns=`vdir -R *.* $dir| awk '{print $8"\t"$5}'`
temp=""
for file in $lns
do
if test $file = "0"
then
printf $temp"\t"$file"\n"
fi
temp=$file
done
but I only get results in that directory file not all files and if any file name has a space then I get only first word followed by tab
Can anyone help me?
This is the correct way to search for size 0:
Search for multiple file extensions of size 0:
Note: If you removed the \( ... \) the results would be all of the files that meet this requirement hence ignoring the size 0.
As addition to the answers above:
If you would like to delete those files
To print the names of all files in and below $dir of size 0:
Note that not all implementations of
find
will produce output by default, so you may need to do:No, you don't have to bother grep.