Executing a string in bash
I've got a script that goes through some nasty regex stuff to produce a text file, which I then make executable and run from within the script like this:
But I'd like to find a more elegant way of doing it. Now let's suppose I'm storing my file to be executed to $FOO instead of to a file. What would be the best way to run the commands listed in that variable?
I've heard of using the "`" special character to run commands in bash, with something like:
But I haven't gotten that to work. Recently, I tried just piping the standard output to bash via:
echo $FOO | bash
And this has been working, but I have a feeling I'm overlooking something more elegant. Any suggestions?