GNU bug report logs - #70860
Add an option to remove filenames for wc util

Previous Next

Package: coreutils;

Reported by: Laurent Lyaudet <laurent.lyaudet <at> gmail.com>

Date: Fri, 10 May 2024 14:31:02 UTC

Severity: normal

To reply to this bug, email your comments to 70860 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#70860; Package coreutils. (Fri, 10 May 2024 14:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Laurent Lyaudet <laurent.lyaudet <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 10 May 2024 14:31:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Laurent Lyaudet <laurent.lyaudet <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Add an option to remove filenames for wc util
Date: Fri, 10 May 2024 13:36:29 +0200
[Message part 1 (text/plain, inline)]
Hello :),

Thanks for your hard work :)
I had a need for a variant of wordcount without filenames in the output,
tuesday.
https://github.com/LLyaudet/DevOrSysAdminScripts/blob/main/build_and_checks_dependencies/lines_filters.sh
https://github.com/LLyaudet/DevOrSysAdminScripts/commit/f0cb3291de4ad0bc63e40baf31364d1af6849f12
I started to make a patch on GNU coreutils on that day,
but I had to interrupt and continue today.
Here is the patch joined to this email.


Best summary of the feature is just to copy-paste my commit message:
wc: Add an option -n --no-filenames.

wc now has an option -n or --no-filenames to remove the filenames
from the output lines.
It is useful when used in conjunction with a single option
-c, -m, -l, -L, or -w,
since the result is a single number per line that can be easily used
in shell (Bash) scripts,
without having to pipe the result with cut.

doc/coreutils.texi: Add option -n to documentation.
NEWS: Mention the change option -n added and justify it.
src/wc.c: Modify the source code to have an option -n.
tests/wc/wc-no-filenames.sh: Test --no-filenames option for wc.


Note that it should be a -f --filenames option if the default was different.
If the default was configurable,
then we should have -f --filenames -n --no-filenames options,
like is possible in some of the latest versions of argparse in Python
(argparse.BooleanOptionalAction).
I don't know how to handle that in C code.
Please accept my patch and improve upon it if needed.

Best regards,
     Laurent Lyaudet
[Message part 2 (text/html, inline)]
[no_filename_option_for_wc.diff (text/x-patch, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#70860; Package coreutils. (Fri, 10 May 2024 16:49:01 GMT) Full text and rfc822 format available.

Message #8 received at 70860 <at> debbugs.gnu.org (full text, mbox):

From: Chris Elvidge <celvidge001 <at> gmail.com>
To: Laurent Lyaudet <laurent.lyaudet <at> gmail.com>, 70860 <at> debbugs.gnu.org
Subject: Re: bug#70860: Add an option to remove filenames for wc util
Date: Fri, 10 May 2024 17:47:10 +0100
Why not use 'wc [options] <filename'
Obv. only works on a single filename.

On 10/05/2024 at 12:36, Laurent Lyaudet wrote:
> Hello :),
> 
> Thanks for your hard work :)
> I had a need for a variant of wordcount without filenames in the output,
> tuesday.
> https://github.com/LLyaudet/DevOrSysAdminScripts/blob/main/build_and_checks_dependencies/lines_filters.sh
> https://github.com/LLyaudet/DevOrSysAdminScripts/commit/f0cb3291de4ad0bc63e40baf31364d1af6849f12
> I started to make a patch on GNU coreutils on that day,
> but I had to interrupt and continue today.
> Here is the patch joined to this email.
> 
> 
> Best summary of the feature is just to copy-paste my commit message:
> wc: Add an option -n --no-filenames.
> 
> wc now has an option -n or --no-filenames to remove the filenames
> from the output lines.
> It is useful when used in conjunction with a single option
> -c, -m, -l, -L, or -w,
> since the result is a single number per line that can be easily used
> in shell (Bash) scripts,
> without having to pipe the result with cut.
> 
> doc/coreutils.texi: Add option -n to documentation.
> NEWS: Mention the change option -n added and justify it.
> src/wc.c: Modify the source code to have an option -n.
> tests/wc/wc-no-filenames.sh: Test --no-filenames option for wc.
> 
> 
> Note that it should be a -f --filenames option if the default was different.
> If the default was configurable,
> then we should have -f --filenames -n --no-filenames options,
> like is possible in some of the latest versions of argparse in Python
> (argparse.BooleanOptionalAction).
> I don't know how to handle that in C code.
> Please accept my patch and improve upon it if needed.
> 
> Best regards,
>       Laurent Lyaudet
> 


-- 

Chris Elvidge






Information forwarded to bug-coreutils <at> gnu.org:
bug#70860; Package coreutils. (Fri, 10 May 2024 19:54:01 GMT) Full text and rfc822 format available.

Message #11 received at 70860 <at> debbugs.gnu.org (full text, mbox):

From: Laurent Lyaudet <laurent.lyaudet <at> gmail.com>
To: Chris Elvidge <celvidge001 <at> gmail.com>
Cc: 70860 <at> debbugs.gnu.org
Subject: Re: bug#70860: Add an option to remove filenames for wc util
Date: Fri, 10 May 2024 21:52:13 +0200
[Message part 1 (text/plain, inline)]
No, it works also with many files.
Hello,
Best regards,
    Laurent Lyaudet

Le ven. 10 mai 2024, 18:47, Chris Elvidge <celvidge001 <at> gmail.com> a écrit :

> Why not use 'wc [options] <filename'
> Obv. only works on a single filename.
>
> On 10/05/2024 at 12:36, Laurent Lyaudet wrote:
> > Hello :),
> >
> > Thanks for your hard work :)
> > I had a need for a variant of wordcount without filenames in the output,
> > tuesday.
> >
> https://github.com/LLyaudet/DevOrSysAdminScripts/blob/main/build_and_checks_dependencies/lines_filters.sh
> >
> https://github.com/LLyaudet/DevOrSysAdminScripts/commit/f0cb3291de4ad0bc63e40baf31364d1af6849f12
> > I started to make a patch on GNU coreutils on that day,
> > but I had to interrupt and continue today.
> > Here is the patch joined to this email.
> >
> >
> > Best summary of the feature is just to copy-paste my commit message:
> > wc: Add an option -n --no-filenames.
> >
> > wc now has an option -n or --no-filenames to remove the filenames
> > from the output lines.
> > It is useful when used in conjunction with a single option
> > -c, -m, -l, -L, or -w,
> > since the result is a single number per line that can be easily used
> > in shell (Bash) scripts,
> > without having to pipe the result with cut.
> >
> > doc/coreutils.texi: Add option -n to documentation.
> > NEWS: Mention the change option -n added and justify it.
> > src/wc.c: Modify the source code to have an option -n.
> > tests/wc/wc-no-filenames.sh: Test --no-filenames option for wc.
> >
> >
> > Note that it should be a -f --filenames option if the default was
> different.
> > If the default was configurable,
> > then we should have -f --filenames -n --no-filenames options,
> > like is possible in some of the latest versions of argparse in Python
> > (argparse.BooleanOptionalAction).
> > I don't know how to handle that in C code.
> > Please accept my patch and improve upon it if needed.
> >
> > Best regards,
> >       Laurent Lyaudet
> >
>
>
> --
>
> Chris Elvidge
>
>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#70860; Package coreutils. (Fri, 10 May 2024 19:55:02 GMT) Full text and rfc822 format available.

Message #14 received at 70860 <at> debbugs.gnu.org (full text, mbox):

From: Laurent Lyaudet <laurent.lyaudet <at> gmail.com>
To: Chris Elvidge <celvidge001 <at> gmail.com>
Cc: 70860 <at> debbugs.gnu.org
Subject: Re: bug#70860: Add an option to remove filenames for wc util
Date: Fri, 10 May 2024 21:53:05 +0200
[Message part 1 (text/plain, inline)]
Pro-tip use globbing.

Le ven. 10 mai 2024, 21:52, Laurent Lyaudet <laurent.lyaudet <at> gmail.com> a
écrit :

> No, it works also with many files.
> Hello,
> Best regards,
>     Laurent Lyaudet
>
> Le ven. 10 mai 2024, 18:47, Chris Elvidge <celvidge001 <at> gmail.com> a
> écrit :
>
>> Why not use 'wc [options] <filename'
>> Obv. only works on a single filename.
>>
>> On 10/05/2024 at 12:36, Laurent Lyaudet wrote:
>> > Hello :),
>> >
>> > Thanks for your hard work :)
>> > I had a need for a variant of wordcount without filenames in the output,
>> > tuesday.
>> >
>> https://github.com/LLyaudet/DevOrSysAdminScripts/blob/main/build_and_checks_dependencies/lines_filters.sh
>> >
>> https://github.com/LLyaudet/DevOrSysAdminScripts/commit/f0cb3291de4ad0bc63e40baf31364d1af6849f12
>> > I started to make a patch on GNU coreutils on that day,
>> > but I had to interrupt and continue today.
>> > Here is the patch joined to this email.
>> >
>> >
>> > Best summary of the feature is just to copy-paste my commit message:
>> > wc: Add an option -n --no-filenames.
>> >
>> > wc now has an option -n or --no-filenames to remove the filenames
>> > from the output lines.
>> > It is useful when used in conjunction with a single option
>> > -c, -m, -l, -L, or -w,
>> > since the result is a single number per line that can be easily used
>> > in shell (Bash) scripts,
>> > without having to pipe the result with cut.
>> >
>> > doc/coreutils.texi: Add option -n to documentation.
>> > NEWS: Mention the change option -n added and justify it.
>> > src/wc.c: Modify the source code to have an option -n.
>> > tests/wc/wc-no-filenames.sh: Test --no-filenames option for wc.
>> >
>> >
>> > Note that it should be a -f --filenames option if the default was
>> different.
>> > If the default was configurable,
>> > then we should have -f --filenames -n --no-filenames options,
>> > like is possible in some of the latest versions of argparse in Python
>> > (argparse.BooleanOptionalAction).
>> > I don't know how to handle that in C code.
>> > Please accept my patch and improve upon it if needed.
>> >
>> > Best regards,
>> >       Laurent Lyaudet
>> >
>>
>>
>> --
>>
>> Chris Elvidge
>>
>>
>>
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#70860; Package coreutils. (Fri, 10 May 2024 21:36:02 GMT) Full text and rfc822 format available.

Message #17 received at 70860 <at> debbugs.gnu.org (full text, mbox):

From: Chris Elvidge <celvidge001 <at> gmail.com>
To: Laurent Lyaudet <laurent.lyaudet <at> gmail.com>
Cc: 70860 <at> debbugs.gnu.org
Subject: Re: bug#70860: Add an option to remove filenames for wc util
Date: Fri, 10 May 2024 22:34:16 +0100
Yes, but if you do it (<filename or wc -n) with more than one file, how 
do you easily sort out which line refers to which file?

On 10/05/2024 at 20:52, Laurent Lyaudet wrote:
> No, it works also with many files.
> Hello,
> Best regards,
>      Laurent Lyaudet
> 
> Le ven. 10 mai 2024, 18:47, Chris Elvidge <celvidge001 <at> gmail.com 
> <mailto:celvidge001 <at> gmail.com>> a écrit :
> 
>     Why not use 'wc [options] <filename'
>     Obv. only works on a single filename.
> 
>     On 10/05/2024 at 12:36, Laurent Lyaudet wrote:
>      > Hello :),
>      >
>      > Thanks for your hard work :)
>      > I had a need for a variant of wordcount without filenames in the
>     output,
>      > tuesday.
>      >
>     https://github.com/LLyaudet/DevOrSysAdminScripts/blob/main/build_and_checks_dependencies/lines_filters.sh
>      >
>     https://github.com/LLyaudet/DevOrSysAdminScripts/commit/f0cb3291de4ad0bc63e40baf31364d1af6849f12
>      > I started to make a patch on GNU coreutils on that day,
>      > but I had to interrupt and continue today.
>      > Here is the patch joined to this email.
>      >
>      >
>      > Best summary of the feature is just to copy-paste my commit message:
>      > wc: Add an option -n --no-filenames.
>      >
>      > wc now has an option -n or --no-filenames to remove the filenames
>      > from the output lines.
>      > It is useful when used in conjunction with a single option
>      > -c, -m, -l, -L, or -w,
>      > since the result is a single number per line that can be easily used
>      > in shell (Bash) scripts,
>      > without having to pipe the result with cut.
>      >
>      > doc/coreutils.texi: Add option -n to documentation.
>      > NEWS: Mention the change option -n added and justify it.
>      > src/wc.c: Modify the source code to have an option -n.
>      > tests/wc/wc-no-filenames.sh: Test --no-filenames option for wc.
>      >
>      >
>      > Note that it should be a -f --filenames option if the default was
>     different.
>      > If the default was configurable,
>      > then we should have -f --filenames -n --no-filenames options,
>      > like is possible in some of the latest versions of argparse in Python
>      > (argparse.BooleanOptionalAction).
>      > I don't know how to handle that in C code.
>      > Please accept my patch and improve upon it if needed.
>      >
>      > Best regards,
>      >       Laurent Lyaudet
>      >
> 
> 
>     -- 
> 
>     Chris Elvidge
> 
> 


-- 

Chris Elvidge





This bug report was last modified 22 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.