I have three arrays which hold three elements each.
I have a fourth array which contains the names of those three arrays.
I'm having difficulty creating a nested loop that can loop through each array and echo their values.
script
#!/bin/ksh
# array of locations (usa, london, australia)
set -A location_arr usa ldn aus
# values in each location (3 values each for test)
set -A usa 34 27 84
set -A ldn 83 49 32
set -A aus 25 36 93
# loop to echo each value of each location
for value in ${location_arr[*]}; do
i=0
while [ $i -lt 3 ]; do
echo "${value}[${i}]->[${value}[${i}]]"
((i=i+1))
done
done
output
usa[0]->[usa[0]]
usa[1]->[usa[1]]
usa[2]->[usa[2]]
ldn[0]->[ldn[0]]
ldn[1]->[ldn[1]]
ldn[2]->[ldn[2]]
aus[0]->[aus[0]]
aus[1]->[aus[1]]
aus[2]->[aus[2]]
the output that I want
usa[0]->[34]
usa[1]->[27]
usa[2]->[84]
ldn[0]->[83]
ldn[1]->[49]
ldn[2]->[32]
aus[0]->[25]
aus[1]->[36]
aus[2]->[93]