GNU bug report logs - #9449
Bug report on 'wc' : characters count adds one character

Previous Next

Package: coreutils;

Reported by: "Laurent TARRISSE" <ltarrisse <at> midilibre.com>

Date: Tue, 6 Sep 2011 14:03:01 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eric Blake <eblake <at> redhat.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#9449: closed (Bug report on 'wc' : characters count adds one
 character)
Date: Tue, 06 Sep 2011 14:30:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Tue, 06 Sep 2011 08:25:28 -0600
with message-id <4E662D58.8080206 <at> redhat.com>
and subject line Re: bug#9449: Bug report on 'wc' : characters count adds one character
has caused the GNU bug report #9449,
regarding Bug report on 'wc' : characters count adds one character
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
9449: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9449
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: "Laurent TARRISSE" <ltarrisse <at> midilibre.com>
To: <bug-coreutils <at> gnu.org>
Subject: Bug report on 'wc' : characters count adds one character
Date: Tue, 6 Sep 2011 15:49:24 +0200
[Message part 3 (text/plain, inline)]
Hi,

Documentation on 'wc' says:
----------------------------------------------
wc -m, --chars
              print the character counts

----------------------------------------------

But here follows the output I get:

>echo toto | wc --chars
5
>echo five | wc --chars
5
>echo four | wc --chars
5
>echo f  | wc --chars
2
>echo "" | wc --chars
1

Why does 'wc' add one character ?

Thanks.

----------------------------------------------
UNIX VERSION:
----------------------------------------------
>uname -a
Linux jdm-qualiac-srv-trv.midilibre.com 2.6.9-100.ELsmp #1 SMP Tue Feb 1 12:04:42 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
>uname -r
2.6.9-100.ELsmp
>cat /etc/issue
Red Hat Enterprise Linux ES release 4 (Nahant Update 9)
Kernel \r on an \m
[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
From: Eric Blake <eblake <at> redhat.com>
To: Laurent TARRISSE <ltarrisse <at> midilibre.com>
Cc: 9449-done <at> debbugs.gnu.org
Subject: Re: bug#9449: Bug report on 'wc' : characters count adds one character
Date: Tue, 06 Sep 2011 08:25:28 -0600
tag 9449 notabug
thanks

On 09/06/2011 07:49 AM, Laurent TARRISSE wrote:
>> echo toto | wc --chars
> 5

Thanks for the report; however, this is correct.  wc is counting the 
newline output by echo.

Try these to see the difference:

$ printf toto | wc --chars
4
$ echo toto | od -tx1z

> Why does 'wc' add one character ?

It doesn't.  Echo does.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


This bug report was last modified 13 years and 326 days ago.

Previous Next


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