GNU bug report logs - #46346
wc --human-readable or --verbose

Previous Next

Package: coreutils;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Sat, 6 Feb 2021 13:56:02 UTC

Severity: wishlist

To reply to this bug, email your comments to 46346 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#46346; Package coreutils. (Sat, 06 Feb 2021 13:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sat, 06 Feb 2021 13:56:02 GMT) Full text and rfc822 format available.

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

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-coreutils <at> gnu.org
Subject: wc --human-readable or --verbose
Date: Sat, 06 Feb 2021 21:38:24 +0800
wc needs a --verbose option. Else one is forced to do:

$ file=e.html; echo $file:; for i in bytes chars lines words; do echo -en $i:\\t; wc --$i < $file; done
e.html:
bytes:  31655
chars:  29141
lines:  643
words:  1275

I mean sometimes we want to send the output to a real person, and
currently all wc makes is:

$ wc e.html
  643  1275 31655 e.html
$ file=e.html; for i in bytes chars lines words; do wc --$i < $file; done
31655
29141
643
1275

So there needs to be a --verbose or --human-readable like du(1)... oops
I don't mean saying 234M... yet.




Information forwarded to bug-coreutils <at> gnu.org:
bug#46346; Package coreutils. (Sat, 06 Feb 2021 15:05:01 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>,
 46346 <at> debbugs.gnu.org
Subject: Re: bug#46346: wc --human-readable or --verbose
Date: Sat, 6 Feb 2021 15:03:51 +0000
On 06/02/2021 13:38, 積丹尼 Dan Jacobson wrote:
> wc needs a --verbose option. Else one is forced to do:
> 
> $ file=e.html; echo $file:; for i in bytes chars lines words; do echo -en $i:\\t; wc --$i < $file; done
> e.html:
> bytes:  31655
> chars:  29141
> lines:  643
> words:  1275
> 
> I mean sometimes we want to send the output to a real person, and
> currently all wc makes is:
> 
> $ wc e.html
>    643  1275 31655 e.html
> $ file=e.html; for i in bytes chars lines words; do wc --$i < $file; done
> 31655
> 29141
> 643
> 1275
> 
> So there needs to be a --verbose or --human-readable like du(1)... oops
> I don't mean saying 234M... yet.

For standard text files, lines < words < bytes
so the counts would be apparent from their relative sizes.
But I agree it's not generally the case,
and also ambiguous as to whether it's chars or bytes by default (it's bytes),
So quite user unfriendly by default.

I see FreeBSD wc supports --libxo,
which supports json output which is a bit more general
and close to what you want:
https://juniper.github.io/libxo/libxo-manual.html

So for this example it would be:

  $ wc --libxo json,pretty,warn e.html
  {
    "wc": {
      "file": [
        {
          "lines": 643,
          "words": 1275,
          "bytes": 31655,
          "filename": "e.html"
        }
      ]
    }
  }

BTW I see that for FreeBSD's wc character and byte counts are mutually exclusive,
so they're always described as "characters" in the output, which is confusing I think.

cheers,
Pádraig




Information forwarded to bug-coreutils <at> gnu.org:
bug#46346; Package coreutils. (Sat, 06 Feb 2021 16:47:01 GMT) Full text and rfc822 format available.

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

From: Chris Elvidge <celvidge001 <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Re: bug#46346: wc --human-readable or --verbose
Date: Sat, 6 Feb 2021 16:46:22 +0000

On 06/02/2021 01:38 pm, 積丹尼 Dan Jacobson wrote:
> wc needs a --verbose option. Else one is forced to do:
> 
> $ file=e.html; echo $file:; for i in bytes chars lines words; do echo -en $i:\\t; wc --$i < $file; done
> e.html:
> bytes:  31655
> chars:  29141
> lines:  643
> words:  1275
> 
> I mean sometimes we want to send the output to a real person, and
> currently all wc makes is:
> 
> $ wc e.html
>    643  1275 31655 e.html
> $ file=e.html; for i in bytes chars lines words; do wc --$i < $file; done
> 31655
> 29141
> 643
> 1275
> 
> So there needs to be a --verbose or --human-readable like du(1)... oops
> I don't mean saying 234M... yet.
> 
> 
> 
> 

Or:
wch () { [[ "$1" && -f "$1" ]] || return 1; awk '{print 
"file:\t"$5"\nlines:\t"$1"\nwords:\t"$2"\nchars:\t"$3"\nbytes:\t"$4}' < 
<(wc -lwcm $1); }



-- 

Chris Elvidge







Severity set to 'wishlist' from 'normal' Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Mon, 21 Feb 2022 10:08:01 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 115 days ago.

Previous Next


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