I have a list of associative array variables that I want to iterate over and retrieve their key / value pairs.
I iterate over one associative array, listing all its keys and getting the values, i.e.
for key in "${!queue1[@]}" do echo "key : $key" echo "value : ${queue1[$key]}" done
The tricky part is that associative array names are variable variables, for example. given count = 5, associative arrays will be called queue1, queue2, queue3, queue4, queue5.
I am trying to replace the above sequence based on a count, but so far each combination of parentheses and eval has not produced much more errors with a bad replacement. for example below:
for count in {1,2,3,4,5} do for key in "${!queue${count}[@]}" do echo "key : $key" echo "value : ${queue${count}[$key]}" done done
Help would be greatly appreciated!
source share