All Questions
Tagged with bash-array indirection
2 questions
2
votes
1
answer
108
views
How to access further members of an array when using bash variable indirection?
Consider the following example, it seems it's working fine with the index 0:
$ a1=(1 2 3)
$ a2=(a b c)
$ for x in a1 a2; do echo "${!x}"; done
1
a
$ for x in a1 a2; do echo "${!x[0]}"; done
1
a
...
0
votes
2
answers
668
views
Concatenating string to form an existing variable name and working within array enclosure format
#!/bin/bash
mat_1=(ServerAB ServerFR ServerPE ServerAM ServerHU)
st="mat_1";
indirect_var='${'${st}'[@]}'
#(Please, see the "--Desired Ouput Section--" in comments)
#----- What ...