Moving files based on size (string to integer)

I have a log file that I want to archive out as it reaches 100MB. I am using the following to get the file size into a variable but get the error "line 5: [: -gr: binary operator expected"
This is still the test code to work out the comparison.

filesize=$(wc -c < logfile.log)
if [ $filesize -gr 100000000 ]
then
  echo "is greater than 100M"
else
  echo "is less than 100M"
fi

I'm sure there's something I'm being braindead on and overlooking. I'm pretty adept at batch files, but this is my initial foray into bash.

Thanks.

You should either use stat or ls -l to get the actual size. wc -c gives you the word count.
And the error is probably because of -gr in the if loop, it should be -gt .

file_size=$( stat -c %s logfile.log )
if [ $file_size -gt 100000000 ]; then
  echo "is greater than 100M"
else
  echo "is less than 100M"
fi

--ahamed

Perfect! Thanks for the change. Bonehead typo -_-