sorry ... mine was a typo, there should be no space between 'be' and 'st' so yes 'best' option is to use a loop of which by the way 'if' is not a loop.
Any of the others can work depending on your choice, but the for loop as shown by GrapefruiTgirl would be my choice.
I would offer some slight adjustments:
Code:
for xx in ${!multiples2[*]}; do
for yy in ${!multiples1[*]}); do
# see if the two variables match:
if (( ${multiples2[xx]} == ${multiples1[yy]} )); then
# if so, add them into an array to print at the end.
out+=( ${multiples1[yy]} )
fi
done
done
# Print the matching numbers:
echo "Common: ${out[*]}"
Changes made for following reasons:
1. ${!array[*]} - * apparently runs quicker and ! will give you indices that have been assigned
2. [index] - variables used as indices do not require $ to be expanded
3. (( )) - doing number testing should be done using these parentheses