Sample Header Ad - 728x90

Why is "${ARRAY[@]}" expanded into multiple words, when it's quoted?

4 votes
1 answer
3466 views
I don't understand why "${ARRAY[@]}" gets expanded to multiple words, when it's quoted ("...")? Take this example: IFS=":" read -ra ARRAY <<< "foo:bar:baz" for e in "${ARRAY[@]}"; do echo $e; done foo bar baz Any other variable that I expand in quotes, say "${VAR}", results in a single word: VAR="foo bar baz" for a in "${VAR}"; do echo $a; done foo bar baz Can anyone explain this to a novice Linux user?
Asked by Shuzheng (4931 rep)
Jan 17, 2020, 05:19 PM
Last activity: May 4, 2023, 08:48 PM