如何在变量中传递值

时间:2016-08-23 12:39:35

标签: linux shell variables unix

我想传递来自其他环境的值${name} 以下更新标志。

$updateflag='${name}.tsting.com'             

$echo ${name}        $TEST        $echo "${updateflag}"     >>>>> I am
getting below              $updateflag='${name}.tsting.com'

我正在寻找类似的东西:

updateflag='TEST.tsting.com'  

任何人都可以提供建议吗?非常感谢提前。

1 个答案:

答案 0 :(得分:0)

这是eval

的情况
name=TEST
updateflag='${name}.foo'
eval declare "expanded=\"$updateflag\""
echo "$expanded"
TEST.foo