I have a question on the test command in the Korn shell (ksh). I know -ne
is for comparing integers and !=
is for comparing strings. How will the test command behave if one argument is a string and the other is an integer. I have below conditions in my code and both are working properly.
myCount=1
myCount=`expr $myCount+ 0`
temp=`ps -aef | grep damn | wc -l`
if [ $temp -ne $myCount]; then
echo ERROR Number
fi
if [ $temp != $myCount ]; then
echo ERROR Strings
fi
Output is
ERROR Number
ERROR Strings