Substituting bash for loop variable to get array name

Viewed 104

I'm trying to use a bash for loop to choose an array, the members of which I want to use as variables in a for loop one level down. My issue is in doing the expansion in the second for loop, which I can't figure out.

first_two_models=( model_one model_two )
second_two_models=( model_three model_four )


for name in first_two second_two; do
    for model in ${"$name_models"[@]}; do
        echo $model
    done
done

Thank you for any help you can offer!

2 Answers
Related