both [[ string1 == string2 ]] and [[ string1 = string2 ]] means equal. But some other guy told me their machine don't support ==. The error message is: syntax error: `==' unexpected.

Seems they use pretty old UNIX with korn shell and I'm using REHL5.2. Since I cannot access their machines, how do I find out which version start to support "=="?



You can look at the value of $SHELL and see if it's set to the shell's executable. You could then test and branch on the value of it, or lack thereof; I don't know if this will be set on older shells.

If you don't need the advanced features of [[ then use [ instead. This web page explains the differences in detail. Also take a look at this related question.

If you are only going to compare strings with == then use the POSIX syntax for the greatest compatibility: [ string1 = string2 ] which uses a single equals sign.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.