In bash, if I have:
y=10 x=\'y\' echo $x # prints \'y\'
Now I want to get $y via $x:
$y
echo ${$x} # error: \"bad sub
See Parameter Expansion in bash manual:
echo ${!x}
Use eval for indirect references while escaping the outer dollar sign
eval
eval echo "\${$x}"
To assign to a variable
eval "z=\${$x}" echo "$z" # 10