[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Wishlist Feature Request: wc
From: |
Stephane Chazelas |
Subject: |
Re: Wishlist Feature Request: wc |
Date: |
Wed, 18 Nov 2015 13:26:08 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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).
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".
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}'
--
Stephane