Hello I'm using bash and I'm getting stuck iterating on associative bidimensional arrays.
I have this arrays:
declare -A x_matrix
x_matrix[ele1,sub1]="asdfadf"
x_matrix[ele2,sub3]="blabla"
x_matrix[ele1,sub2]="no matters"
x_matrix[ele3,sub1]="opps"
elements=(ele1 ele2 ele3)
And I want to iterate with the known elements in something like this
for e in ${elements[@]}; do
for sub in ${!x_matrix[$e,@]}; do
echo "($e,$sub)> ${x_matrix[$e,$sub]}"
done
done
And I something like:
(ele1,sub1)> asdfadf
(ele1,sub2)> no matters
(ele2,sub3)> blabla
(ele3,sub1)> opps
I can't see how to do this but I believe that it should be possible.
[Edit] I have checked this: BASH: need some help with multidimensional associative arrays And the solution provided didn't fit my needs.