[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
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.
--
Benjamin A'Lee <bma@xxxxxxxxxxxxxx>
http://subvert.org.uk/~bma/
"It's hard to live up to your principles. If it were easy, your
principles probably aren't worth a damn anyway." - Mark Pilgrim
Attachment:
signature.asc
Description: Digital signature
-- 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