Os nomes das variáveis dinâmicas são complicados no bash, mas realizáveis com a variável indireta.
numbers=(0 1 2 3 4 5 6 7 8)
colors=(red blue green)
loop_sequence=(numbers numbers colors numbers colors colors)
# keep track of where you are in each array
declare -A idx=([numbers]=0 [colors]=0)
for varname in "${loop_sequence[@]}"; do
tmp="${varname}[${idx[$varname]}]" # construct the array reference
echo "$varname => ${!tmp}" # variable indirection gets the value
(( idx[$varname]++ ))
done
saídas
numbers => 0
numbers => 1
colors => red
numbers => 2
colors => blue
colors => green
Para repetir indefinidamente o loop_sequence, você pode:
declare -A idx=([numbers]=0 [colors]=0)
# store the array sizes for convenience
declare -A size=([numbers]=${#numbers[@]} [colors]=${#colors[@]})
while true; do
for varname in "${loop_sequence[@]}"; do
tmp="${varname}[${idx[$varname]}]"
echo "$varname => ${!tmp}"
# loop the array index
(( idx[$varname] = (idx[$varname]+1) % size[$varname] ))
done
done | less