I wrote in the terminal:
arr=(1 2 3)
for x in $arr; do
echo $x
done
and it just prints '1'. Why doesn't it print 1 2 3 ?
To expand to all the elements of an array, use "${arr[@]}"
for x in "${arr[@]}"; do
When you use the array name as an ordinary variable, without indexing it, it expands to the first element.