Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i check, for a empty file? 4

Status
Not open for further replies.

elpis13

IS-IT--Management
Dec 12, 2005
7
Hello,

i have to check on my script, if the file Test empty is. How can i do that?

Thank you!
 
if test -s /path/to/file/Test
then
echo "file /path/to/file/Test is empty"
fi

see man page for test command

HTH,

p5wizard
 
Of course Feherke, you are quite right!
My post should have read:

if test -s /path/to/file/Test
then
echo "file /path/to/file/Test is NOT empty"
fi

OR

if test ! -s /path/to/file/Test
then
echo "file /path/to/file/Test is empty"
fi



HTH,

p5wizard
 
Wow, a star for that? To be honest, that should have been Feherke's [blush].

HTH,

p5wizard
 
Faster today, but my initial reply was WRONG...

HTH,

p5wizard
 
I just want to thank you both! I m new, i don 't know jet how it s works.

THANK YOU BOTH!!!
:)))
 
Or

find . -size 0 -print > list_of_empty_files

while read line
do
echo file being moved $line
mv $line /emptyfiles
done < list_of_empty_files

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top