Thank you for your answer. Now that I see your solution I have a D'oh!
moment. There is only one problem. You won't see that stdin and files are
treated differently by running wc --help or in the man page, just through
info coreutils which I don't know how many people think about checking.

Cheers,

Tom


On Tue, Feb 11, 2014 at 9:30 PM, Eric Blake <[email protected]> wrote:

> On 02/11/2014 01:26 PM, Thomas Bohm wrote:
> > Hey,
> >
> > By playing with a word list today I noticed I can't compute the number of
> > average letters / word by simply doing a calc `wc -m file`/`wc -l file`
> > because the filename is part of the output if wc is run on a file (on
> stdin
> > it is suppressed). This is why I added a new flag -q so that a user can
> > suppress that part of the output I will.  I don't have high hopes of it
> > getting accepted, but I said I try :)
>
> Thanks for the suggestion, but this already does what you want:
>
> calc `wc -m < file`/`wc -l < file`
>
> That is, POSIX requires that when reading from stdin rather than from a
> filename, then there will be no filename in the output of wc.  As this
> is already a standard way to suppress the output, I see no need to add a
> -q.
>
> --
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
>

Reply via email to