PDA

View Full Version : bash: greater than



takayuki
July 30th, 2010, 02:21 AM
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 :)


for FILENAME in *.jpg #traverse filenames...

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

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

done

exit 0

seungwon
July 30th, 2010, 02:55 AM
I think you should change > with -gt.

ghostdog74
July 30th, 2010, 02:58 AM
if [[ $FILESIZE > 50000 ]] ;then
...
fi

seungwon
July 30th, 2010, 03:10 AM
How about this?



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

takayuki
July 30th, 2010, 03:19 AM
thanks!

if [[ $FILESIZE > 50000 ]] ;then

did the trick.

syntax!