我正在尝试:
declare -a array=(first second third)
for i in ${array[@]}; do
${i}_arg=$(some commands here...)
done
预期结果:
first_arg=something1
second_arg=something2
third_arg=something3
我怎样才能做到这一点?
最佳答案
我解决了我在变量名前添加“export”的问题。不确定这是否是最好的方法。
关于Bash 变量名是连接的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29980194/