How to compare file size in script?
Hongwei Li
hongwei at wustl.edu
Mon Aug 15 16:06:38 UTC 2005
Hi,
I want to write a script to compare file sizes. My script is like this:
#!/bin/sh
ls -l /tmp/test/t1 | awk '{print $5}' > thesize
echo `cat thesize`
if [ `cat thesize` > 300000 ]
then
echo "big file: thesize"
exit 0
fi
But, no matter how small or big the file t1 is, it always display:
11190
big file: thesize
The actual size of t1 is 11190. I also tried the other code:
#!/bin/sh
thissize=`ls -l /tmp/test/t1 | awk '{print $5}'`
echo "$thissize"
if [ $thissize > 300000 ]
then
echo "big file: $thissize"
exit 0
fi
then, it displays:
11190
big file: 11190
What's wrong in the codes? How to fix it?
Thanks!
Hongwei Li
More information about the fedora-list
mailing list