How to use "not equal to " in IF statement

Hi,
i need to compare two variables by using if statement

if [ $var1 -ne $var2 ] 
 then 
  echo "$var1"
 else 
  echo "$var2"
fi

where -ne is used for not equal to but this is not working and giving me a syntax error. can anybody tel me how use not equal to with 'if' in ksh

thanks

if [ $var1 != $var2 ] 
then 
echo "$var1"
else 
echo "$var2"
fi

thanks Ikon.... it's working fine now.. :slight_smile:

try to do it in KSH....

#!/bin/ksh
if [[ "$var1" -ne "$var2" ]] ; then
  echo "$var1"
else 
  echo "$var2"
fi