GNU bug report logs -
#79710
[PATCH] ls: add --count and --count-list options to display file, directory, and symlink counts and counts with list of contents
Previous Next
To reply to this bug, email your comments to 79710 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org:
bug#79710; Package
coreutils.
(Tue, 28 Oct 2025 16:36:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Debkanta Mondal <debkantaroni01 <at> gmail.com>:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org.
(Tue, 28 Oct 2025 16:36:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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 (debkantaroni01 <at> gmail.com)
[ls-count-feature.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org:
bug#79710; Package
coreutils.
(Tue, 28 Oct 2025 16:53:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 79710 <at> debbugs.gnu.org (full text, mbox):
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 (debkantaroni01 <at> gmail.com)
It's hard to review this patch as it's mostly reindented changes.
Can you resend with just the logic changes.
Can you give example outputs from the new options.
Note new options to ls have a high bar.
thanks,
Padraig
Information forwarded
to
bug-coreutils <at> gnu.org:
bug#79710; Package
coreutils.
(Tue, 28 Oct 2025 17:17:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 79710 <at> debbugs.gnu.org (full text, mbox):
On 2025-10-28 09:52, Pádraig Brady wrote:
> Can you give example outputs from the new options.
> Note new options to ls have a high bar.
Yes, my first reaction was, "Why do we need a --count option when we
have 'ls | wc'"?
Whatever else is in the patch, it needs an item in NEWS briefly
explaining why it's needed. (I didn't read the patch as I was hoping
someone else would review it....)
Information forwarded
to
bug-coreutils <at> gnu.org:
bug#79710; Package
coreutils.
(Tue, 28 Oct 2025 17:58:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 79710 <at> debbugs.gnu.org (full text, mbox):
Pádraig Brady <P <at> draigBrady.com> 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 (debkantaroni01 <at> gmail.com)
>
> 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
Information forwarded
to
bug-coreutils <at> gnu.org:
bug#79710; Package
coreutils.
(Tue, 28 Oct 2025 19:20:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 79710 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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 (debkantaroni01 <at> gmail.com)
On Tue, Oct 28, 2025 at 11:27 PM Collin Funk <collin.funk1 <at> gmail.com> wrote:
>
> Pádraig Brady <P <at> draigBrady.com> 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 (debkantaroni01 <at> gmail.com)
> >
> > 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
[ls-count-cleaned.patch (application/octet-stream, attachment)]
[NEWS-for-count.patch (application/octet-stream, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org:
bug#79710; Package
coreutils.
(Tue, 28 Oct 2025 23:29:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 79710 <at> debbugs.gnu.org (full text, mbox):
On 2025-10-28 12:18, Debkanta Mondal wrote:
> With --count, you get
> everything in one place: directories, files, links, and the table
Sure, but we get all that info with -l already.
Counting is just one of many things that one can already do with the
output of 'ls', and one cannot reasonably expect to have an 'ls' option
for every possible form of postprocessing. Suppose I want to count every
regular file with permission -r--r--r--, for example - should we have a
separate 'ls' option for that too?
It's simpler to leave 'ls' alone and process its output as needed.
> no need extra pipeline/
> complex command for this simple and frequently required output
I don't see that it's frequently required.
Information forwarded
to
bug-coreutils <at> gnu.org:
bug#79710; Package
coreutils.
(Wed, 29 Oct 2025 02:56:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 79710 <at> debbugs.gnu.org (full text, mbox):
Hello Paul Eggert,
Thanks for the feedback. I understand your point about not adding an
option for every possible form of postprocessing.
However, my motivation for --count isn’t to replace shell pipelines,
but to expose structured information that
is already gathered internally while scanning directories. While ls |
wc -l gives a quick total, it’s not reliable
when filenames contain newlines, and it can’t distinguish between
directories, regular files, and symbolic links.
The --count option provides these accurate, categorized counts
directly, without extra parsing or the risk of incorrect results.
In that sense, it’s not arbitrary postprocessing — it’s using ls’s
existing internal data to present summary statistics in a simple and
consistent way.
And normally from a new user's perspective, it comes to try with the
--count option intuitively if they don't know about pipelines
just only for this matter to know the count of categorized type of
elements and its list. and later on if more post processing
required users will definitely search more ways of using the pipeline.
Thanks again for the review and consideration!
Signed-off-by: Debkanta Mondal (debkantaroni01 <at> gmail.com)
On Wed, Oct 29, 2025 at 4:58 AM Paul Eggert <eggert <at> cs.ucla.edu> wrote:
>
> On 2025-10-28 12:18, Debkanta Mondal wrote:
> > With --count, you get
> > everything in one place: directories, files, links, and the table
>
> Sure, but we get all that info with -l already.
>
> Counting is just one of many things that one can already do with the
> output of 'ls', and one cannot reasonably expect to have an 'ls' option
> for every possible form of postprocessing. Suppose I want to count every
> regular file with permission -r--r--r--, for example - should we have a
> separate 'ls' option for that too?
>
> It's simpler to leave 'ls' alone and process its output as needed.
>
> > no need extra pipeline/
> > complex command for this simple and frequently required output
>
> I don't see that it's frequently required.
Information forwarded
to
bug-coreutils <at> gnu.org:
bug#79710; Package
coreutils.
(Wed, 29 Oct 2025 03:13:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 79710 <at> debbugs.gnu.org (full text, mbox):
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.
Information forwarded
to
bug-coreutils <at> gnu.org:
bug#79710; Package
coreutils.
(Wed, 29 Oct 2025 03:52:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 79710 <at> debbugs.gnu.org (full text, mbox):
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 (debkantaroni01 <at> gmail.com)
On Wed, Oct 29, 2025 at 8:42 AM Paul Eggert <eggert <at> cs.ucla.edu> 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.
This bug report was last modified 9 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.