From unknown Sun Sep 07 03:05:43 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#9449 <9449@debbugs.gnu.org> To: bug#9449 <9449@debbugs.gnu.org> Subject: Status: Bug report on 'wc' : characters count adds one character Reply-To: bug#9449 <9449@debbugs.gnu.org> Date: Sun, 07 Sep 2025 10:05:43 +0000 retitle 9449 Bug report on 'wc' : characters count adds one character reassign 9449 coreutils submitter 9449 "Laurent TARRISSE" severity 9449 normal tag 9449 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 06 10:02:44 2011 Received: (at submit) by debbugs.gnu.org; 6 Sep 2011 14:02:44 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R0wEc-0007rQ-DY for submit@debbugs.gnu.org; Tue, 06 Sep 2011 10:02:44 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R0w9K-00072Y-Mj for submit@debbugs.gnu.org; Tue, 06 Sep 2011 09:57:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0w5e-0000lf-4n for submit@debbugs.gnu.org; Tue, 06 Sep 2011 09:53:27 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,HTML_MESSAGE, RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:36942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0w5e-0000lb-3K for submit@debbugs.gnu.org; Tue, 06 Sep 2011 09:53:26 -0400 Received: from eggs.gnu.org ([140.186.70.92]:44798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0w5a-000155-0P for bug-coreutils@gnu.org; Tue, 06 Sep 2011 09:53:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0w5V-0000jk-NC for bug-coreutils@gnu.org; Tue, 06 Sep 2011 09:53:21 -0400 Received: from mail.midilibre.com ([193.104.54.20]:30255 helo=smtp.midilibre.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0w5V-0000jC-HU for bug-coreutils@gnu.org; Tue, 06 Sep 2011 09:53:17 -0400 Received: from unknown (HELO smtp-av2.site) ([192.168.60.12]) by ironport2priv.midilibre.com with ESMTP; 06 Sep 2011 15:53:12 +0200 Received: from mdl-msg-smtp.midilibre.com (unknown [192.34.11.5]) by smtp-av2.site (Postfix) with ESMTP id 01E4517C93 for ; Tue, 6 Sep 2011 15:53:12 +0200 (CEST) Received: from mdl-msg-mdg2.midilibre.com ([192.34.11.6]) by mdl-msg-smtp.midilibre.com (Lotus Domino Release 8.0.1) with ESMTP id 2011090615530928-443038 ; Tue, 6 Sep 2011 15:53:09 +0200 Received: from GES1356 ([192.34.11.72]) by mdl-msg-mdg2.midilibre.com (Lotus Domino Release 8.0.1) with SMTP id 2011090615530718-13994 ; Tue, 6 Sep 2011 15:53:07 +0200 Message-ID: <00b401cc6c9c$4e0c51f0$480b22c0@GES1356> From: "Laurent TARRISSE" To: Subject: Bug report on 'wc' : characters count adds one character Date: Tue, 6 Sep 2011 15:49:24 +0200 MIME-Version: 1.0 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-MIMETrack: Itemize by SMTP Server on mdl_msg_mdg2/SRV/GML(Release 8.0.1|February 07, 2008) at 09/06/2011 03:53:07 PM, Serialize by Router on mdl_msg_mdg2/SRV/GML(Release 8.0.1|February 07, 2008) at 09/06/2011 03:53:09 PM, Serialize complete at 09/06/2011 03:53:09 PM, Itemize by SMTP Server on mdl_msg_smtp/SRV/GML(Release 8.0.1|February 07, 2008) at 06/09/2011 15:53:09, Serialize by Router on mdl_msg_smtp/SRV/GML(Release 8.0.1|February 07, 2008) at 06/09/2011 15:53:11, Serialize complete at 06/09/2011 15:53:11 X-TNEFEvaluated: 1 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00A5_01CC6CAC.8D5F27A0" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -6.6 (------) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 06 Sep 2011 10:02:40 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) This is a multi-part message in MIME format. ------=_NextPart_000_00A5_01CC6CAC.8D5F27A0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" 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 ------=_NextPart_000_00A5_01CC6CAC.8D5F27A0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="iso-8859-1"
Hi,
 
Documentation on 'wc' = says:
----------------------------------------------
wc&nb= sp;-m,=20 --chars
          &n= bsp;  =20 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=20 --chars
2
>echo "" | wc = --chars
1
 
Why does 'wc' add one character = ?
 
Thanks.
 
----------------------------------------------
UNIX = VERSION:
----------------------------------------------
>u= name=20 -a
Linux jdm-qualiac-srv-trv.midilibre.com 2.6.9-100.ELsmp #1 SMP Tue = Feb 1=20 12:04:42 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
>uname=20 -r
2.6.9-100.ELsmp
>cat /etc/issue
Red Hat Enterprise Linux = ES=20 release 4 (Nahant Update 9)
Kernel \r on an = \m
------=_NextPart_000_00A5_01CC6CAC.8D5F27A0-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 06 10:29:19 2011 Received: (at 9449-done) by debbugs.gnu.org; 6 Sep 2011 14:29:19 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R0weM-0000iH-Pu for submit@debbugs.gnu.org; Tue, 06 Sep 2011 10:29:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R0weK-0000iA-Te for 9449-done@debbugs.gnu.org; Tue, 06 Sep 2011 10:29:17 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p86EPSkA030996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Sep 2011 10:25:29 -0400 Received: from [10.3.113.103] (ovpn-113-103.phx2.redhat.com [10.3.113.103]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p86EPSD9023805; Tue, 6 Sep 2011 10:25:28 -0400 Message-ID: <4E662D58.8080206@redhat.com> Date: Tue, 06 Sep 2011 08:25:28 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.20) Gecko/20110817 Fedora/3.1.12-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.12 MIME-Version: 1.0 To: Laurent TARRISSE Subject: Re: bug#9449: Bug report on 'wc' : characters count adds one character References: <00b401cc6c9c$4e0c51f0$480b22c0@GES1356> In-Reply-To: <00b401cc6c9c$4e0c51f0$480b22c0@GES1356> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -10.3 (----------) X-Debbugs-Envelope-To: 9449-done Cc: 9449-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.3 (----------) 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@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 06 10:32:04 2011 Received: (at 9449) by debbugs.gnu.org; 6 Sep 2011 14:32:04 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R0wh1-0001Ta-6x for submit@debbugs.gnu.org; Tue, 06 Sep 2011 10:32:04 -0400 Received: from mailout-eu.gmx.com ([213.165.64.43]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1R0wgy-0001TA-6X for 9449@debbugs.gnu.org; Tue, 06 Sep 2011 10:32:02 -0400 Received: (qmail invoked by alias); 06 Sep 2011 14:22:36 -0000 Received: from static-218-149-228-77.ipcom.comunitel.net (EHLO rowlf.zhilabs.net) [77.228.149.218] by mail.gmx.com (mp-eu002) with SMTP; 06 Sep 2011 16:22:36 +0200 X-Authenticated: #48875277 X-Provags-ID: V01U2FsdGVkX18M7l1Cew0M7vWO/U9LffhdwaAddGfC7WPX6cr1cr iI1mxOZzMDfWh5 Date: Tue, 6 Sep 2011 16:22:00 +0200 From: Davide Brini To: 9449@debbugs.gnu.org Subject: Re: bug#9449: Bug report on 'wc' : characters count adds one character Message-ID: <20110906162200.2401d257@rowlf.zhilabs.net> In-Reply-To: <00b401cc6c9c$4e0c51f0$480b22c0@GES1356> References: <00b401cc6c9c$4e0c51f0$480b22c0@GES1356> Organization: Not organized X-Mailer: Claws Mail 3.7.10 (GTK+ 2.24.6; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: 9449 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.3 (---) On Tue, 6 Sep 2011 15:49:24 +0200, "Laurent TARRISSE" 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. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 20 14:00:18 2011 Received: (at control) by debbugs.gnu.org; 20 Sep 2011 18:00:18 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R64cE-0001Nm-1X for submit@debbugs.gnu.org; Tue, 20 Sep 2011 14:00:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R64cA-0001HV-6g for control@debbugs.gnu.org; Tue, 20 Sep 2011 14:00:16 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8KHt5Ml011230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Sep 2011 13:55:05 -0400 Received: from [10.3.113.135] (ovpn-113-135.phx2.redhat.com [10.3.113.135]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8KHt4iN031217 for ; Tue, 20 Sep 2011 13:55:05 -0400 Message-ID: <4E78D378.3060907@redhat.com> Date: Tue, 20 Sep 2011 11:55:04 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.22) Gecko/20110906 Fedora/3.1.14-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.14 MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: more work Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -10.3 (----------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.3 (----------) tag 9507 notabug forcemerge 6394 9507 tag 9504 notabug tag 9449 notabug tag 9450 wishlist tag 9418 notabug tag 9380 notabug tag 9327 notabug tag 9326 notabug tag 9283 notabug tag 9281 notabug thanks -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org From unknown Sun Sep 07 03:05:43 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 19 Oct 2011 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator