I have a bunch of arrays like this:
array1=("A" "B")
array2=("C" "D")
array3=("E" "F" "G")
And I want to loop over the arrays, and the elements in each. Here is how I'm trying to accomplish this:
for i in `seq 1 2`
do
for elm in ${array${i}[@]}
do
echo "the element in array$i is $elm"
done
done
But, this gives me:
./new_test.sh: line 6: ${array${i}[@]}: bad substitution
I sort of know that what I'm doing is wrong, because I don't want the first $ to evaluate the ${i} inside of it.
How do I prevent this?