I would like to ask some help regarding variable variables in bash. I've read a few articles about it, but in my case I don't know how to do it. Let see my problem:
The array contains other arrays' names and I want to print the values of these arrays. In inner for I need variable variables.
#!/bin/bash
declare -a array=(dir1 dir2 dir3)
declare -a dir1=(1 2 3)
declare -a dir2=(a b c)
declare -a dir3=(9 8 7)
for elem1 in "${array[@]}"
do
for elem2 in "${variableVariable[@]}"
do
echo "$elem1 : $elem2"
done
done
The output should be something like this
dir1 : 1 dir1 : 2 dir1 : 3 dir2 : a dir2 : b dir2 : c dir3 : 9 dir3 : 8 dir3 : 7