views:

33

answers:

3

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 compare * as a literal?. I have tried with all possible ways like including $1 in double quotes, single quotes, [].

+3  A: 

It's expanded by the shell so you have to pass it to the script either in quotes or escaped:

echo '*'
echo "*"
echo \*
Ignacio Vazquez-Abrams
A: 

You problem is that you need to quote the constant *, not the parameter that you are comparing it to.

bmargulies
+2  A: 

it should not be a problem, the script:

#! /bin/bash

if [[ "$1" == '*' ]]
then
  echo EQ
else
  echo NE
fi

The execution:

./aaa.bash '*'
Drakosha