I get confused on array syntax in bash. I typically use quotes to enclose strings to loop through, but tutorials typically use parentheses. For kicks I made 4 simple loops. The first two work as I expected by echoing each item in the array, the second two gave unexpected output.
Why does this happen?
LOOP #1
$ List="item1 item2 item3"
$ for f in $List; do echo ${f}; done
item1
item2
item3
LOOP #2
$ List=(item1 item2 item3)
$ for f in ${List[@]}; do echo ${f}; done
item1
item2
item3
LOOP #3
$ List="item1 item2 item3"
$ for f in ${List[@]}; do echo ${f}; done
item1
item2
item3
item2
item3
LOOP #4
$ List=(item1 item2 item3)
$ for f in $List; do echo ${f}; done
item1