${(@)…}: 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 is a Zsh IDE with support for ${(@)…}try it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal