${(W)…}: Word count, including empty words
W used together with #name counts words in arrays or string.
Contrary to (w), it also counts empty words.
Flag (s) can be used to define the word delimiter.
Links
Examples
- Count words, including empty words
- Output:
1 2 3string="string-with---several-words" echo "With empty words: ${(Ws:-:)#string}" echo "Without empty words: ${(ws:-:)#string}"1 2With empty words: 6 Without empty words: 4
BashSupport Pro 是一款支持 W** 的 **Zsh 集成开发环境 - 立即试用!