Tim Desjardins
Использование цикла for с входной строкой будет разбито на пробелы.
LIST="value1 value2 value3" for x in $LIST ; do echo $x done
Урожайность
value1 value2 value3
или же
LIST="value1 value2 value3" set -A STRING "$LIST" for x in $STRING ; do echo $x done
Урожайность
value1 value2 value3
Richard Hoskins
Вы можете использовать массив.
LIST="value1 value2 value3" set -A values $LIST echo $ value1
Martin Mann
Piping through sed and optionally grep works too
LIST="value1 value2 value3" ; echo "$LIST" | sed 's/[[:space:]]/\n/g' | grep .
You can drop the grep if you also drop the quotes which removes multiple spaces though other formatting may be effected.
LIST="value1 value2 value3" ; echo $LIST | sed 's/[[:space:]]/\n/g'