bug#79710: [PATCH] ls: add --count and --count-list options to display file, directory, and symlink counts and counts with list of contents

Debkanta Mondal <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <CAJPp_Tm-bYe6UB+ZBXevJGd1rC6tSe8ZACFC7LLicd682iwWfg@mail.gmail.com>
Hello @Paul Eggert Sir,

I have understood your point - filenames with newlines are rare, and
ls --count wouldn’t change that limitation.
I don't know if I am going in the right direction or not as per GNU
coreutils philosophy and POSIX.
But my idea is mainly to provide a simple, built-in summary of files,
dirs, and links, using data ls already collects,
so users don’t need to pipe through wc or find for a simple quick overview.

I understand the concern about adding too many options in ls; I’ll
consider whether this functionality fits better as a small
external tool.

Thanks again for the review and consideration!

Signed-off-by: Debkanta Mondal ([email protected])


On Wed, Oct 29, 2025 at 8:42 AM Paul Eggert <[email protected]> wrote:
>
> On 2025-10-28 19:55, Debkanta Mondal wrote:
> >   While ls |
> > wc -l gives a quick total, it’s not reliable
> > when filenames contain newlines
>
> Neither does ls --count, right? Because file names with newlines can
> contain substrings that look like counts (this would be particularly a
> problem with ls -R). Plus, such file names are so rare, and POSIX plans
> to outlaw them, and if you care about them anyway you can use ls --zero,
> and so forth.
>
> Things might be different if this was a common need that 'ls | wc'
> didn't satisfy, but I don't see it.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.