I have defined multiple arrays:
array1=(el1 el2 el3 el4 el5)
array2=(el10 el12 el14)
array3=(el5 el4 el11 el8)
I need to iterate through all elements of all arrays. The following is the syntax I use:
for j in {1..3}
do
for (( k = 0 ; k < ${#array$j[*]} ; k++ ))
do
#perform actions on array elements, refer to array elements as "${array$j[$k]}"
done
done
However, the above snippet fails with the message(s)
k < ${#array$j[*]} : bad substitution and
${array$j[$k]}: bad substitution
What is wrong with my array syntax?
$jand$k, or can you just writefor value in "${array1[@]}" "${array2[@]}" "${array3[@]}" ; do ... ; done?