Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Counting characters in command output?



On Tue, 13 Feb 2024 at 21:39, Mark J. Reed <markjreed@xxxxxxxxx> wrote:
I thought this would give me the length of the string, but it seems to be counting words instead:

     zsh% echo ${#$(echo hello)}
     1

Is this a bug? I thought I'd need a modifier flag to treat output as an array and give me  a word count, while character count would be the default.

Process substitution gives you an array. Quote it if you need a scalar.

Roman.


Messages sorted by: Reverse Date, Date, Thread, Author