O'Reilly logo

Ubuntu Unleashed 2013 Edition: Covering 12.10 and 13.04, Eighth Edition by Matthew Helmke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Comparing Expressions with tcsh

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.

String Comparison

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required