Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 13 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

you can try this:

ls -l | awk -F " " '{if ($5 == 0) print $9}'

Zero byte file of working dir.

share|improve this answer

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.