Skip to content
Advertisement

Shell param doesn’t pass with command

I use the following code to execute shell command, the issue is that when I put it as parameter which I should get from user it doesn’t work but If I put it hard-coded it works.

Working

VAL=`./test a | grep '^.(bpassb)?.$' | cut -d ' ' -g1`

Not working

VAL=`./test a | grep ${param} | cut -d ' ' -g1`

In the not working version which I do cat to param I see the value printed OK, what could I miss when I pass ${param} ?

Advertisement

Answer

Parameters in shell are $1 $2 $3 etc… Right now what you typed is empty data.

You might need to put “” around the $1 parameter. And make sure that the value of $1 is indeed the correct value.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement