The following operators can be used to compare two string expressions: == To compare whether two strings are equal
! = To compare whether two strings are not equal
The following examples compare two strings, stringi and string2, in the shell program comparei:
set string2 = "abd"
if (stringi == string2) then echo "stringi equal to string2" else echo "stringi not equal to string2" endif if (string2 != stringi) then echo "string2 not equal to stringi" else echo "string2 equal to stringi" endif
If you execute comparei, you get the following results:
stringi not equal to string2 string2 not equal to stringi
Was this article helpful?