I am exceuting a shell script from windows machine through plink. I want to compare the "*" (passed as command line argument) to a literal in my script. Can anyone suggest me the way to comp开发者_如何学运维are * as a literal?. I have tried with all possible ways like including $1 in double quotes, single quotes, [].
It's expanded by the shell so you have to pass it to the script either in quotes or escaped:
echo '*'
echo "*"
echo \*
it should not be a problem, the script:
#! /bin/bash
if [[ "$1" == '*' ]]
then
echo EQ
else
echo NE
fi
The execution:
./aaa.bash '*'
You problem is that you need to quote the constant *, not the parameter that you are comparing it to.
精彩评论