Friday, May 20, 2005

Bash shell scripting (string testing)

The question was recently asked how are you supposed to correctly test for a string in a conditional statement in shell script?

Contrary to my initial suspicion the operators:

-eq
-ne
-gt
...

Are to be used for integer comparison and as a result result vary wildly.

Making correct operators used for string comparison I found are:

=
!=

0 Comments:

Post a Comment

<< Home