Results 1 to 5 of 5

Thread: bash: greater than

  1. #1
    Join Date
    Mar 2006
    Beans
    135
    Distro
    Ubuntu

    Question bash: greater than

    Hi,

    trying to create a bash script that will shrink jpegs that are larger than 50kb in a directory on my server.

    Here's what I've got so far, very early in the process...

    the if line errors out with a "command not found". oops.

    anyone have any thoughts here for the noob bash scripter?

    thanks

    PHP Code:
    for FILENAME in *.jpg  #traverse filenames...

        
    do
        
    FILESIZE=$(stat -c%"$FILENAME")

            if [
    "$FILESIZE50000]
            
    then
            
    echo "$FILENAME is too large = $FILESIZE bytes."
            
    fi

        done

    exit 
    Last edited by takayuki; July 30th, 2010 at 02:23 AM.

  2. #2
    Join Date
    Jul 2010
    Beans
    3

    Re: bash: greater than

    I think you should change > with -gt.

  3. #3
    Join Date
    Sep 2006
    Beans
    2,914

    Re: bash: greater than

    Code:
    if [[ $FILESIZE > 50000 ]] ;then
      ...
    fi

  4. #4
    Join Date
    Jul 2010
    Beans
    3

    Re: bash: greater than

    How about this?

    Code:
    if [ "$FILESIZE" -gt 50000 ]
    then
            echo "$FILENAME is too large = $FILESIZE bytes."
    fi

  5. #5
    Join Date
    Mar 2006
    Beans
    135
    Distro
    Ubuntu

    Re: bash: greater than

    thanks!

    if [[ $FILESIZE > 50000 ]] ;then

    did the trick.

    syntax!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •