Hello Coreutils maintainers,

I have attached cleaned logic specific patch file for --count and
--count-list and also
 NEWS patch file for detailed explanation from my side to propose
these changes still after having "ls | wc" with this mail.

Output: If current directory have 5 files, 2 directories and 0 link: then
ls --count
Directories: 2 | Files: 5 | Links: 0
ls --count-list
Directories: 2 | Files: 5 | Links: 0
----------------------------------------------------------------------------------------
CONTAINING ELEMENTS ARE
----------------------------------------------------------------------------------------
Name                           Type   Permissions   Size
Modified
----------------------------------------------------------------------------------------
ABOUT-NLS                 FILE   -rw-r--r--        93787    2023-03-13 23:42
AUTHORS                    FILE   -rw-r--r--        3827
2023-03-13 23:38
COPYING                     FILE   -rw-r--r--        35149
2023-03-13 23:38
ChangeLog                   FILE   -rw-r--r--        324062
2023-04-18 20:02
GNUmakefile                FILE   -rw-r--r--         4589
2023-04-18 19:39
build                              DIR    drwxr-xr-x      160
2025-10-28 23:56
build-aux                       DIR    drwxr-xr-x       800
2023-04-18 20:02


Why do we need a --count option when we have 'ls | wc'"?
    ls --count will count the number of directories, files and symlinks
of current directory user present. and --count-list will print the
count and also print containing items details - like name, size,
permissions, modified datetime, and its type. With --count, you get
everything in one place: directories, files, links, and the table,
without needing to chain commands like ls | wc. It’s simpler, more reliable,
and avoids issues with pipes or parsing output. And --count-list can
give a detailed table of contained elements with type wise count and
all within the ls , just using options flag , no need extra pipeline/
complex command for this simple and frequently required output

The patch was tested on coreutils-9.3 using `make check`, and all tests passed.

Thank you for maintaining Coreutils and for reviewing my contribution!

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


On Tue, Oct 28, 2025 at 11:27 PM Collin Funk <[email protected]> wrote:
>
> Pádraig Brady <[email protected]> writes:
>
> > On 28/10/2025 15:45, Debkanta Mondal wrote:
> >>   my-count-and-count-list-ls-update.patch
> >> Hello Coreutils maintainers,
> >> This patch adds two new options to `ls`:
> >>    --count       : Display the total number of directories, files and
> >> symbolic links.
> >>    --count-list  : Display a detailed count + list of directories,
> >> files and symbolic links present in the current directory.
> >> The purpose of this update is to make it easier for users to quickly
> >> see
> >> object counts when listing directory contents.
> >> The patch was tested on coreutils-9.3 using `make check`, and all
> >> tests passed.
> >> I have attached the patch file with this email.
> >> Thank you for maintaining Coreutils and for reviewing my
> >> contribution!
> >> Signed-off-by: Debkanta Mondal ([email protected])
> >
> > It's hard to review this patch as it's mostly reindented changes.
> > Can you resend with just the logic changes.
>
> Likewise. The HACKING file has good formatting settings for vim.
>
> The Emacs settings could be improved to add '(c-set-style "GNU")', among
> other things.
>
> Other editors I have tried are bad at GNU formatting.
>
> > Can you give example outputs from the new options.
> > Note new options to ls have a high bar.
>
> My feeling is that the feature is not really needed with GNU find:
>
>     $ find . -maxdepth 1 -type d | wc -l
>     39
>     $ find . -maxdepth 1 -type f | wc -l
>     35
>     $ find . -maxdepth 1 -type l | wc -l
>     2
>
> Collin

Attachment: ls-count-cleaned.patch
Description: Binary data

Attachment: NEWS-for-count.patch
Description: Binary data

Reply via email to