Every once in a while I need to use dynamic variables in shell scripts for doing things like
echo ${{$foo}_bar}
but unfortunately it won’t work like shown in the example above.
What will work however is this:
test="foo"
foo_bar="it works!"
foo=$(eval "echo \${$(echo ${test}_bar)"-''})
echo $foo
foo_bar="it works!"
foo=$(eval "echo \${$(echo ${test}_bar)"-''})
echo $foo
