GNU bug report logs -
#9449
Bug report on 'wc' : characters count adds one character
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9449 in the body.
You can then email your comments to 9449 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#9449
; Package
coreutils
.
(Tue, 06 Sep 2011 14:03:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
"Laurent TARRISSE" <ltarrisse <at> midilibre.com>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Tue, 06 Sep 2011 14:03:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (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 2 (text/html, inline)]
Reply sent
to
Eric Blake <eblake <at> redhat.com>
:
You have taken responsibility.
(Tue, 06 Sep 2011 14:30:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
"Laurent TARRISSE" <ltarrisse <at> midilibre.com>
:
bug acknowledged by developer.
(Tue, 06 Sep 2011 14:30:03 GMT)
Full text and
rfc822 format available.
Message #10 received at 9449-done <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org
:
bug#9449
; Package
coreutils
.
(Tue, 06 Sep 2011 14:33:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 9449 <at> debbugs.gnu.org (full text, mbox):
On Tue, 6 Sep 2011 15:49:24 +0200, "Laurent TARRISSE"
<ltarrisse <at> midilibre.com> wrote:
> 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 ?
wc isn't adding anything. If you do "echo toto" you're sending five
characters to the pipe. Try this:
echo toto | od -c
--
D.
Added tag(s) notabug.
Request was from
Eric Blake <eblake <at> redhat.com>
to
control <at> debbugs.gnu.org
.
(Tue, 20 Sep 2011 18:01:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 19 Oct 2011 11:24:04 GMT)
Full text and
rfc822 format available.
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.