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.
我在 bash 中有三个数组。
arr1=(arr2 arr3) arr2=(1 2 3 4) arr3=(6 7 8 9) #How can I get a element of arr2 by arr1? like below: ${${arr1[0]}[0} # To get first element in arr2
一个eval少的答案:
eval
tmp=arr1[0] tmp2=${!tmp} echo ${!tmp2[0]}
使用评估:
eval echo \${${arr1[0]}[0]}