scripting question - Redhat

This is a discussion on scripting question - Redhat ; Scripting question: How would I go about checking the size of a file in directory and storing the size in a variable to use later?...

+ Reply to Thread
Results 1 to 4 of 4

Thread: scripting question

  1. scripting question

    Scripting question:
    How would I go about checking the size of a file in directory and storing
    the size in a variable to use later?



  2. Re: scripting question

    On Mon, 24 May 2004 22:55:20 GMT, Robert Smith wrote:
    > Scripting question:
    > How would I go about checking the size of a file in directory and storing
    > the size in a variable to use later?


    Try this
    set - $(ls -al /etc/profile)
    echo $5

  3. Re: scripting question

    On Mon, 24 May 2004 23:06:33 GMT, Bit Twister
    wrote:

    >On Mon, 24 May 2004 22:55:20 GMT, Robert Smith wrote:
    >> Scripting question:
    >> How would I go about checking the size of a file in directory and storing
    >> the size in a variable to use later?

    >
    >Try this
    > set - $(ls -al /etc/profile)
    > echo $5


    Or this...
    [root@www tmp]# cat root/bin/sizeof
    #!/bin/bash

    /usr/bin/stat -c %s $1

    #eof

    An example of usage would be something like...

    LIMIT=1000
    for FILE in *
    do
    SIZ=`sizeof $FILE`
    if $SIZ > $LIMIT
    then
    echo "$FILE is > $LIMIT"
    else
    echo "$FILE is <= $LIMIT"
    fi
    done


    Brad
    --
    "Laughter is good medicine and it has no bad side effects."
    Unknown
    Bradley W. Olin
    http://www.bwo1.com

  4. Re: scripting question

    On Tue, 25 May 2004 01:14:19 GMT, Brad Olin wrote:

    > if $SIZ > $LIMIT


    Whoops, that should read...
    if $SIZ -gt $LIMIT


    integer compare vrs string compare

    Brad
    --
    "Laughter is good medicine and it has no bad side effects."
    Unknown
    Bradley W. Olin
    http://www.bwo1.com

+ Reply to Thread