Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: better grammar with $#
On Sun, Oct 30, 2022 at 3:17 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
>
> output=$( eval "$@" ) # Input here is a 'find' command outputting a list of files.
> tmp=( ${(f)output} ) # Count lines not characters.
> linecount=$#tmp
You can combine the two expansions:
linecount=${#${(f)output}}
> And is it lines or words there?
It's lines.
If you can replace the `find` command with a glob, it'll be simpler.
You'll also avoid quoting issues. If your code is supposed to handle
all sorts of file names, make sure it can handle files with backslash
and line feed in their names.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author