Reputation: 19
I would like to execute a shell script which is having below code .
value=`echo "false"`
case $1 in "26492|26851|27407|26493")
value=`echo "true"`
;;
esac
If the first argument is one of the values specified, a word true will be printed otherwise, false will be printed
26492|26851|27407|26493
I am not getting the required output.
I have executed like this sh -x script name 27407
.
Can some one please help in this ?
Upvotes: 0
Views: 118
Reputation: 131435
There are two issues here:
|
) within the quotation marks, since that makes bash treat that entire string as a single possible value.echo
statement is enclosed in back-ticks, and that's assigned to value
. So what happens is that instead of getting true
as the output, you're getting the value of value
changed.Try:
case $1 in 26492|26851|27407|26493)
echo "true"
;;
esac
Upvotes: 2