Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有以下两个变量:
arg1=5 count5="test"
现在,我希望能够执行以下操作:
echo ${'count' . $arg1} #which should give me "test" but its returning bad-substitution error
即可以将变量的一部分设置为bash 中的变量吗?
好的,通过 Bash v2 中引入的间接变量引用使其工作:
my_var="count$arg1" echo ${!my_var}