如何从变量中获取环境值?

How to get environment value from variable?

如果我有一个 var,其值为 HOME、PATH 或 My_Var 等,我如何从 var 中获取 $HOME、$PATH?

如下所示:

VAR="HOME"
echo ${$VAR} # does not work

就这么简单:

VAR="HOME"
echo ${!VAR}

More on indirect references