comparing strings as ints

Hi, So I got his code below. $year is a string of 2010,2011 etc.
I guess I want to convert $year to an integer so I can do my if statement to see if the year string is greater than 2010? Or how could I do this?

Right now I get a syntax error doing this.

if[ $year > 2010 ]; then
do stuff
fi

What shell are you using?

Try: if (( $year > 2010 )); then do stuff; fi
or: if [ $year -gt 2010 ]; then do stuff; fi
--
Bye

The test utility's

s1 > s2

primary (which is an extension to the standards) performs a string comparison; the

s1 -gt s2

primary (which is required by the standards) performs a numeric comparison.

As an example:

if [ 5 > 10 ]
then echo string comparison
else echo numeric comparison

prints string comparison but:

if [ 5 -gt 10 ]
then echo string comparison
else echo numeric comparison

prints numeric comparison .

And, you got the syntax error because you need a space between the if and the [; i.e., if [ ... instead of if[ ...