Hi,
For some reason I've always thought that to compare numbers in kornshell scripts, you use " -eq ", while for strings you use " == ". In fact, my bolsky/korn book says that the only way to compare strings is with " == ", not " = ", as this is obsolete. However, on our HP UNIX system " == " simply will not work... error messages stating that the == operator was unexpected are returned. " = " does work, however. Some websites advise usage of " -eq " for everything, but this also won't work, as
returns "they are equal as strings...", which is clearly false. I'm confused... is " = " the accepted, non-obsolete string comparison operator, despite what my book claims?
Thanks,
dora
For some reason I've always thought that to compare numbers in kornshell scripts, you use " -eq ", while for strings you use " == ". In fact, my bolsky/korn book says that the only way to compare strings is with " == ", not " = ", as this is obsolete. However, on our HP UNIX system " == " simply will not work... error messages stating that the == operator was unexpected are returned. " = " does work, however. Some websites advise usage of " -eq " for everything, but this also won't work, as
Code:
if [[ "1" -eq "1.0" ]]
then
echo "they are equal as strings...";
else
echo "not equal";
fi;
returns "they are equal as strings...", which is clearly false. I'm confused... is " = " the accepted, non-obsolete string comparison operator, despite what my book claims?
Thanks,
dora