From: "Mark J. Reed" <markjreed@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Counting characters in command output?
Date: Tue, 13 Feb 2024 19:45:58 -0500 [thread overview]
Message-ID: <CAA=-s3z3dwdPY4ahJSOZZC7_vH5VwUJxt-UEo9BW=8qzu0WTSg@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMrWzYgyGYghHsp1jEcnN=X+bUM8LDXviL4V+mHtnHpq8A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 761 bytes --]
On Tue, Feb 13, 2024 at 3:41 PM Roman Perepelitsa <
roman.perepelitsa@gmail.com> wrote:
> On Tue, 13 Feb 2024 at 21:39, Mark J. Reed <markjreed@gmail.com> 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.
>
You mean command substitution, but thanks! It wouldn't have occurred to me
to put quotes around it to change what the `#` was counting!
--
Mark J. Reed <markjreed@gmail.com>
[-- Attachment #2: Type: text/html, Size: 1786 bytes --]
next prev parent reply other threads:[~2024-02-14 0:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 20:38 Mark J. Reed
2024-02-13 20:41 ` Roman Perepelitsa
2024-02-14 0:45 ` Mark J. Reed [this message]
2024-02-14 6:49 ` Roman Perepelitsa
2024-02-14 13:56 ` Mark J. Reed
2024-02-14 15:36 ` Ray Andrews
2024-02-14 15:58 ` Mark J. Reed
2024-02-14 16:30 ` Ray Andrews
2024-02-15 14:34 ` Lawrence Velázquez
2024-02-15 9:50 ` Roman Perepelitsa
2024-02-15 14:30 ` Lawrence Velázquez
2024-02-15 15:29 ` Ray Andrews
2024-02-15 16:16 ` Roman Perepelitsa
2024-02-15 16:55 ` Ray Andrews
2024-02-15 14:53 ` Ray Andrews
2024-02-16 1:53 ` Bart Schaefer
2024-02-16 4:53 ` Lawrence Velázquez
2024-02-16 18:03 ` Bart Schaefer
2024-02-16 18:38 ` Mark J. Reed
2024-02-16 19:36 ` Bart Schaefer
2024-02-16 19:37 ` Lawrence Velázquez
2024-02-16 21:06 ` Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAA=-s3z3dwdPY4ahJSOZZC7_vH5VwUJxt-UEo9BW=8qzu0WTSg@mail.gmail.com' \
--to=markjreed@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).