I\'m trying to substitute a string variable, containing multiple quoted words, as a parameter to a command.
Thus, given the following example script (Note the -x in
Don't use quotes, use an array (see BashFAQ #050):
$ myArgs=("hello" "world" "multiword arg with * ?")
+ myArgs=("hello" "world" "multiword arg with * ?")
$ echo "${myArgs[@]}"
+ echo hello world 'multiword arg with * ?'
hello world multiword arg with * ?
If it really needs to be in the form of quoted strings within a string, you're either going to have to use something like eval "echo $myArg" (which can cause some really nasty bugs, if you aren't careful) or parse it yourself (which is going to be difficult).