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

时间:2015-07-05 14:36:40

标签: bash environment

如果我有一个var,其值是HOME,PATH或My_Var等,我如何从var获得$ HOME,$ PATH?

如下所示:

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

1 个答案:

答案 0 :(得分:4)

就这么简单:

VAR="HOME"
echo ${!VAR}

More on indirect references