December 2012
Intermediate to advanced
888 pages
48h 24m
English
As stated earlier, the method for comparing expressions in tcsh is different from the method used under pdksh and bash. The comparison of expression demonstrated in this section uses the syntax necessary for the tcsh shell environment.
You can use the following operators 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, string1 and string2, in the shell program compare1:
#!/bin/tcshset string1 = "abc"set string2 = ""abd"if (string1 == string2) then echo "string1 equal to string2"else echo ""string1 not equal to string2"endifif (string2 != string1) then echo ""string2 ...
Read now
Unlock full access