1753485 Members
4683 Online
108794 Solutions
New Discussion юеВ

Re: check file size

 
SOLVED
Go to solution
Leo The Cat
Regular Advisor

check file size

Hi

I'm in a ksh script. I need to test the size of a file.

Is there a way with if [[ -s file .....

What is the syntax ?

Bests Regards
Den
4 REPLIES 4
Steven E. Protter
Exalted Contributor

Re: check file size

Ivan Ferreira
Honored Contributor
Solution

Re: check file size

I would use something like:

FSIZE=$(ls -la $FILE | awk '{print $5}')
if [ $FSIZE <-lt|-eq|-ne|-gt> ]
then

fi
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Leo The Cat
Regular Advisor

Re: check file size

Thanks Guys
Kannan V
New Member

Re: check file size

if [ -s filename ]
the condition is true if the file exist and has a size greater than zero.