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: Bob Proulx
Subject: Re: wc -m count is wrong
Date: Thu, 3 Jul 2008 12:13:30 -0600
User-agent: Mutt/1.5.13 (2006-08-11)

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]