Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to execute two commands stored in one bash variable

Tags:

bash

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

like image 225
Richard Avatar asked Aug 09 '12 17:08

Richard


1 Answers

Try:

eval ${run2}

This should help.

like image 158
favoretti Avatar answered Sep 20 '22 17:09

favoretti