Issue
foo=username
bar=foo
a=$(eval echo \$$bar) # same as ${!bar}
echo $(eval echo \$${a^^}) # expected val
How to get the value of foo through the variable bar, Same as the above output
I know it wants a variable name not a string here.
echo $(eval echo \$${${!bar}^^}) # error bad substitution
Solution
I believe this is what you want to start with:
foo=username
bar=$foo
... where username
is the literal string, you want to put in the variable, named foo
, and $foo
is the value of the variable foo
, which you want to put in the variable, named bar
.
If you want to create another variable, let's say a
, which contains the value of bar
, you just do:
a=$bar
Answered By - Dominique Answer Checked By - Marie Seifert (WPSolving Admin)