coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wishlist Feature Request: wc


From: Pádraig Brady
Subject: Re: Wishlist Feature Request: wc
Date: Wed, 18 Nov 2015 13:57:05 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 18/11/15 13:26, Stephane Chazelas wrote:
> 2015-11-18 22:55:34 +1100, Craig Sanders:
>> wc would be improved if it had two new options:
>>
>>    --no-total
>>    --no-filenames
>>
>> These would eliminate the need to pipe into `awk '$2 != "total" {print
>> $1}'` or similar to remove totals and filenames from the output when wc
>> has more than one file arg.
> [...]
> 
> I'd second that.
> 
> Note that grep's equivalent option is -h, --no-filename (no
> plural).
> 
> Another addition could be --with-total, so that the total always
> be included even if there's only one argument (as in wc
> --with-total ./*.txt).

You can hack that with:
  wc file /dev/null

> Note that the awk '$2 != "total" {print $1}' is not reliable
> unless you can guarantee filenames don't contain newline
> characters and are not called "total" or
> "total[[:blank:]]anything".


expanding on the previous hack you could:
  wc file1 ... /dev/null | head -n-2

> A
> 
>   -Z, --null                print 0 byte after FILE name
> 
> like grep's (to pipe to awk -vRS='\0' or sed/sort -z for
> instance) would help.
> 
> For now, one needs to do things like:
> 
> wc -l ./*.txt | awk '/\//{print $1}'
> 
> or
> 
> find .//. -name '*.txt' -exec wc -l {} + | awk '
>    /\/\// {print $1}'

Yes we're looking at adding --zero to more tools,
and it might suffice in this edge case to support
robust processing by external tools.

thanks,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]