${(j:string:)…}: Splitting with shell parsing

Join array elements using the option as string separator.

Options

string
The string which is used to join the array elements.

Examples

Join array elements into lines
1
2
3
data=(first second third)
# p to support escape sequence \n
echo ${(pj:\n:)data}
Output:
1
2
3
first
second
third
BashSupport Pro is a Zsh IDE with support for ${(j)…}try it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal