bug-coreutils
[Top][All Lists]
Advanced

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

RE: wc -m count is wrong


From: Hossain, Syed
Subject: RE: wc -m count is wrong
Date: Thu, 3 Jul 2008 15:27:17 -0400

Bob

Thanks for getting back to me promptly. I can understand now why wc
increasing it by one but it is obviously, the explanation you gave me
should be documented in man page or info page, agreed? Thanks.

Syed

-----Original Message-----
From: Bob Proulx [mailto:address@hidden 
Sent: Thursday, July 03, 2008 2:14 PM
To: Hossain, Syed
Cc: address@hidden
Subject: Re: wc -m count is wrong

Hossain, Syed wrote:
> I am surprised that I could not found any posting related to this,

Here is a recent one.  :-)

  http://lists.gnu.org/archive/html/bug-coreutils/2008-04/msg00238.html

> /home/shossain$ echo 1234 | wc -m
> 5
> Obviously I was expecting a count of 4 but wc printed out 5. I have
> tried different string and the count is always increased by one.

The newline on the end of the line is a character.  You can see this
by using od to dump the values.

  echo 1234 | od -tx1 -c
  0000000 31 32 33 34 0a
            1   2   3   4  \n

Of course wc is behaving correctly here.

Bob




reply via email to

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