Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How to find all zero bytes files in directory and even in subdirectories

i done this

lns=`vdir -R *.* $dir| awk '{print $8"\t"$5}'`
for file in $lns

if test $file = "0"
printf $temp"\t"$file"\n"

but i get only in that directory file not all files and if any file name has space i get onlyfirst word followed by tab

can any one help me

share|improve this question
Question also posted on stackoverflow - please don't post the same question in multiple places. –  glenn jackman Mar 29 '13 at 14:34
ok i never repeate it again –  Civa Mar 29 '13 at 15:58

1 Answer 1

up vote 11 down vote accepted

find is an easy way to do this-:

find . -size 0

or if you require a long listing append the -ls option

find . -size 0 -ls
share|improve this answer
Thanks its working great and simple :) –  Civa Mar 29 '13 at 13:03
can i filter files in a directory other than *.xml files –  Civa Mar 29 '13 at 13:22
Yes you can - find . ! -name \*.xml -size 0 –  suspectus Mar 29 '13 at 13:25
@Civa You can even do find . -empty –  terdon Mar 29 '13 at 13:31
Yes indeed -empty will return zero sized files and empty directories. –  suspectus Mar 29 '13 at 13:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.