How to compare file size in script?

Steven W. Orr steveo at syslang.net
Mon Aug 15 17:20:20 UTC 2005


=>Hongwei Li wrote:
=>> Hi,
=>> 
=>> I want to write a script to compare file sizes.  My script is like this:
=>> 
=>> #!/bin/sh
    #!/bin/bash
=>> ls -l /tmp/test/t1 | awk '{print $5}' > thesize
    set -- (ls -l /tmp/test/t1)
    filesize=$5
=>> echo `cat thesize`
    echo $filesize
=>> if [ `cat thesize` > 300000 ]
    if (( filesize > 300000 ))
=>> then
=>>         echo "big file: thesize"
=>>         exit 0
=>> fi
=>> 
=>> But, no matter how small or big the file t1 is, it always display:
=>> 


-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net




More information about the fedora-list mailing list