i am testing with the shell script below:
#!/bin/ksh -x instance=`echo $1 | cut -d= -f2` if [ $instance == "ALL" ] then echo "strings matched \n" fi
It's giving this error in the if condition:
: ==: unknown test operator
== really not the correct syntax to use?
I am running on the command line as below
Could anybody please suggest a solution. Thanks.
I see that you are using ksh, but you added bash as a tag, do you accept a bash-related answer? Using bash you can do it in these ways:
if [[ "$instance" == "ALL" ]] if [ "$instance" = "ALL" ] if [[ "$instance" -eq "ALL" ]]
See here for more on that.
To compare strings you need a single =, not a double. And you should put it in double quotes in case the string is empty:
if [ "$instance" = "ALL" ] then echo "strings matched \n" fi