I have 1 array and 2 associative array. I want to loop through both associative array using a master array list because i want the code to be maintainable. But i cant seems to get it right.
When i tried to print out the keys value in my associative array the result is always 0.
Below are my sample code
declare -A list_a list_b
list_a=( [a]=1 [b]=2)
list_b=( [c]=3 [d]=4)
master_list=(list_a list_b)
for thelist in "${master_list[@]}"
do
for key in "${!thelist[@]}"
do
#it show be printing out the keys of the associative array
echo "the key is: $key"
done
done
Output:
the key is: 0
the key is: 0
Any idea what the problem could be?