${(@)…}: 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 是一款支持 @** 的 **Zsh 集成开发环境 - 立即试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款