syntax of if condition in ksh is wrong

The syntax of 'if' conditionals in bash and ksh seems different. I am trying to check for a particular version using 'if' in ksh. This very simple syntax gives syntax error. I have tried many variants, but no go. Please correct the syntax. Later I will expand it to 'if' and 'else'.

#!/bin/ksh
version=$(head -1 /home/final_reports/version)
echo "version is $version" #prints 2.2
if [[ $version -ge 2.1 ]]; then #gives syntax error
echo "version is correct" 
fi

Thanks in advance.

You can't do real number comparisons. -ge is for integers.

try with >= (instead of ge)

-ge, -lt, -eq...etc... are for integer comparison

AFAIK, you'll have to do this (in ksh 88):

#!/bin/ksh
version_major=2
version_minor=2
echo "version is $version_major.${version_minor}"
if [[ $version_major -ge 2 && $version_minor -ge 1  ]]�
then�
   echo "version is correct"�
fi

Thank you purdym and itkamaraj for your quick help.

I used -ge and it is working. But why is that the simple syntax of if-else not working?

#!/bin/ksh
version=$(head -1 /home/final_reports/version)
echo "version is $version" #prints 2.2
if [[ $version -le 2.1 ]]; then 
echo "version is correct"
else
echo "version is wrong"
fi

I have changed "ge" to "le". So this should print "version is wrong". But it still prints "version is correct".

Please let me know what is wrong in the above syntax.

Where can I learn ksh scripting better?. I got many sites, but the examples given in them are very simple and easy ones. So it does not help when doing real world tasks.

Thanks in advance.

If you are using a non legacy ksh release, this should work

#!/bin/ksh
version=$(head -1 /home/final_reports/version)
echo "version is $version" #prints 2.2
if [[ $(( version > 2.1 )) == 1 ]]
then 
     echo "version is correct"
else
     echo "version is wrong"
fi

No need to do

if [[ $(( version > 2.1 )) == 1 ]]

in ksh93

This works just as well and is a cleaner syntax

if (( version > 2.1 ))
then
     echo "version is correct"
else
     echo "version is wrong"
fi

Thank you jlliagre and fpmurphy!

Indeed, I was fooled by:

$ echo $KSH_VERSION
Version JM 93t+ 2010-03-05
$ version=2.2
$ if (( version > 2.1 ))
ksh93:  version > 2.1 : arithmetic syntax error

but just found it was due to a locale issue.