First page Back Continue Last page Graphics

Note about loops and string compares

If you try to use a simple comparison like:

while (( $var==“fred” )) # numerical

or

while [[ $var==“fred” ]] # character

It sometimes, as in once in a while, won’t seem to work correctly.

Bash can be very picky at times when dealing with strings. I've heard this error reported but it's not very likely. If you should run into it, use:

while echo $var | grep -q "^fred$"