Reputation: 15542
Let's say there is one bash variable
run1="date"
I need to execute date
by
${run1}
And it works, since it prints current time. But if I put two commands in the variable,
run2="date; echo foo"
I can't execute the commands stored in variable run2
, since ${run2}
complains
date;: command not found
Upvotes: 9
Views: 6232
Reputation: 62369
Try eval "${run2}"
. That will interpret the variable as a sequence of commands to be run.
Upvotes: 2