bug-coreutils
[Top][All Lists]
Advanced

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

bug#46346: wc --human-readable or --verbose


From: Pádraig Brady
Subject: bug#46346: wc --human-readable or --verbose
Date: Sat, 6 Feb 2021 15:03:51 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Thunderbird/84.0

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





reply via email to

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