Reputation: 2735
Just a simple question.
I have an array:
array=("1 2 3" "4 5 6")
If I do:
echo ${array[0]}
echo ${array[1]}
1 2 3 or 4 5 6 will be shown.
However, if I do:
for iter in ${array[@]}
do
echo $iter
done
The shown value is not as I expected.... Can anyone give me the right way to use it?
Upvotes: 1
Views: 101
Reputation: 77085
Quotation is what you need:
for iter in "${array[@]}"; do
echo "$iter"
done
Upvotes: 4