Question

For the following value of FOO:

$ FOO='echo `echo hello`'
$ $FOO
`echo hello`

how can I get the expected output:

hello

Basically, how can I interpret a command substitution in the contents of a variable?

Was it helpful?

Solution

Answering the question as given,

eval $FOO

but you're probably going about your real problem the wrong way.

OTHER TIPS

Try this

$ FOO="echo `echo hello`"
$ $FOO 

Just replace single quotes with double quotes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top