Lookup variable value from string in shell script

bash

Solution

See Parameter Expansion in bash manual:

echo ${!x}

Problem

In bash, if I have: ``` y=10 x='y' echo $x # prints 'y' ``` Now I want to get `$y` via $x: ``` echo ${$x} # error: "bad substitution"; I want to print 10 ``` How do I lookup the variable value with name `$x`?

Original source