Say I have an env variable:
export foo="bar";
declare z="\$foo";
I want to echo the value of "$z", which should be "bar". But if I run:
echo "$z"
I get this literal:
$foo
and if I run this instead:
echo "$(eval "$z")"
I get bar is not a command
.
But instead I am looking to just get
"bar"
as the echoed result. How can I do that?