So I have a bash script that is generating a string of commands that I want to be run. The output looks something like
$ program "command1 command2 ... commandN"
But the program is interpreting (as it should) "command1 command2 ... commandN" as one argument.
Is there away to turn pass the string into the argument as split arguments so the program would interpret each command as an individual argument?
$ program command1 command2 ... commandN
Thanks for any help.
I've done this, implementing your scenario :
The idea is to use "a b c" as argument for cat
$ echo a > a
$ echo b > b
$ echo c > c
$ args="a b c"
Trying "a b c" as "one argument"
$ cat $args
cat: a b c: No such file or directory
Workaround to separate arguments :
$ cat $(echo $args)
a
b
c
Hope it helps you
(So you should run program $(echo "command1 command2 ... commandN")