For a nested loop that uses two or more arrays, e.g.
A=(0.1 0.2)
B=(2 4 6)
AB=$((${#A[@]}*${#B[@]})) # total number of iterations (length of A * length of B)
for a in ${A[*]}; do
for b in ${B[*]}; do
$(($a+$b)) # task using each combination of A and B
echo ? # show number of the iteration (i.e. 1 to length of AB)
done
done
What is the best way to get the number of the iteration, as shown above using echo?