ims_lenor
5th August 2004, 10:42
Does anybody know how i can get the size of a specific file into a variable in shell?

or in a if-clause?

like this:

if[filesize>0]
then
echo "hooray"
else
echo "niet"
fi

Han Brinkman
5th August 2004, 12:12
SZ=`ls -l filename | awk '{print $6}'`
echo $SZ

ims_lenor
5th August 2004, 12:15
hmm... this returns the create-month of the file!

patvdv
5th August 2004, 15:26
SZ=`ls -l filename | awk '{print $6}'`
echo $SZ

Should the 5th field:

SZ=`ls -l filename | awk '{print $5}'`
echo $SZ

ims_lenor
5th August 2004, 15:29
thx4help

it works with the parameter -ls!