In bash, how can I echo the variable name, not the variable value?
If you want to simply output a static variable name, you can escape the $
-sign:
echo \$var
The shell parameter expansion ${!name@} or ${!name*} could do the trick,
$ foo=bar
$ var_name=(${!foo@})
$ echo $var_name" = "$foo
foo = bar
Although feasible I can't imagine the utility of this ...