[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
Quoting Benjamin A'Lee <bma+lists@xxxxxxxxxxxxxx>: > On Wed, Sep 19, 2007 at 02:54:17PM +0100, Rob Beard wrote: >> Hi folks, >> >> I'm trying to write a bash script to check if a file is larger than a >> certain size (say 15KB) and if it isn't to run another command. >> >> The closest thing I have found is the test command which can check if >> a file exists and is bigger than 0 bytes. >> >> I don't suppose anyone knows how to check the file sizes and run on a >> certain condition do they? > > `stat -c '%s'` will give you file size in bytes. So try > > test `stat -c '%s' $file` -ge 15360 || echo $file > > to print the filename if it's less than 15KB. Ahh brilliant, thanks guys, I managed to get what I needed with the following... file=/tmp/asc/091707.ASC size=`stat -c %s $file` if [ $size < 15000 ] then echo "No" fi Not pretty but does the job. That'll save me endless hours of messing around with VB.Net :-) Rob -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html