${(@)…}: Array elements as separate words

In double quotes, array elements are put into separate words.

Examples

Expand array values into separate words
1
2
3
4
5
value=(one two three)
# with the flag, each value is expanded into a word
for f in "${(@)value}"; do echo "with flag: $f"; done
# without the flag, it's expanded into just one word
for f in "${value}"; do echo "without flag: $f"; done
Output:
1
2
3
4
with flag: one
with flag: two
with flag: three
without flag: one two three
BashSupport Pro ist eine Zsh IDE mit Unterstützung für ${(@)…} - probieren Sie es jetzt aus!
© 2020–2024 Joachim Ansorg
Impressum
Datenschutz
Rechtliches