bash - Concatenate command string in a shell script -


i maintaining existing shell script assigns command variable in side shell script like:

my_command="/bin/command -dosomething" 

and later on down line passes "argument" $my_command doing :

my_argument="fubar"  $my_command $my_argument 

the idea being $my_command supposed execute $my_argument appended.

now, not expert in shell scripts, can tell, $my_command not execute $my_argument argument. however, if do:

my_argument="itworks" my_command="/bin/command -dosomething $my_argument" 

it works fine.

is valid syntax call $my_command $my_argument executes shell command inside shell script my_argument argument?

it works way expect work, fubar going second argument ( $2 ) , not $1.
if echo arguments in /bin/command this:

echo "$1" # prints '-dosomething' echo "$2" # prints 'fubar' 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -