【发布时间】:2015-01-12 06:05:41
【问题描述】:
我正在尝试读取之前定义的 bash 变量的值,但是这个变量名是动态派生的。
这是我正在尝试做的 bash 脚本
$ mythreshold=10
$ table=my
$ threshold="$table"threshold
$ echo $("$threshold")
mythreshold
但是当我尝试读取这个变量值时
$ echo $("$threshold")
-bash: mythreshold: command not found
但是我期待它打印出来
$ echo $("$threshold")
10
有没有办法让我完成这项工作,它应该打印出上面定义的 mythreshold 变量的值
【问题讨论】:
标签: linux bash shell scripting sh