${(s:string:)…}: Splitting separator

s:string: defines the splitting separator string when word splitting is applied.

The complete string is used as separator. With an empty string each character is split into a separate word.

Examples

Split by string
1
2
3
value="Sunday-Monday-Tuesday-Wednesday-Thursday-Friday-Saturday"
days=( ${(s:-:)value} )
typeset days
Output:
1
days=( Sunday Monday Tuesday Wednesday Thursday Friday Saturday )
BashSupport Pro is a Zsh IDE with support for ${(s)…}try it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal