Please use ***
[code][/code] tags*** around your code and data, to preserve formatting and to improve readability. Please do
not use quote tags, bolding, colors, or other fancy formatting.
It's vital in scripting to understand how the shell handles arguments and whitespace:
http://mywiki.wooledge.org/Arguments
http://mywiki.wooledge.org/WordSplitting
http://mywiki.wooledge.org/Quotes
A
for loop processes one "word" at a time. When you expand the variable, it gets broken into words based on whitespace. Unless you quote it, in which case the whole string gets treated as a single word.
http://wiki.bash-hackers.org/syntax/ccmd/classic_for
Don't Read Lines With For
This is why you should never store
lists of things in a single variable. That's what
arrays are for.
The above posts show generally how to do it, but see here for more details:
http://mywiki.wooledge.org/BashFAQ/005
Finally though, for the simple requirements listed above, we don't even need a loop, just
printf, which has implicit looping built in.
Code:
oses=( "Gentoo 2012" "CentOS 5.4" "Windows 7 Professional" )
printf 'Hey %s\n' "${oses[@]}"