문제

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?

도움이 되었습니까?

해결책

Answering the question as given,

eval $FOO

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

다른 팁

Try this

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

Just replace single quotes with double quotes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top