GNU bug report logs - #18585
Bad count in WC command?

Previous Next

Package: coreutils;

Reported by: "Schapovalov, Sebastian" <sebastian.schapovalov <at> telefonica.com>

Date: Mon, 29 Sep 2014 20:36:02 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: "Schapovalov, Sebastian" <sebastian.schapovalov <at> telefonica.com>
Subject: bug#18585: closed (Re: bug#18585: Bad count in WC command?)
Date: Mon, 29 Sep 2014 20:48:04 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#18585: Bad count in WC command?  

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 18585 <at> debbugs.gnu.org.

-- 
18585: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18585
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Eric Blake <eblake <at> redhat.com>
To: "Schapovalov, Sebastian" <sebastian.schapovalov <at> telefonica.com>,
 18585-done <at> debbugs.gnu.org
Subject: Re: bug#18585: Bad count in WC command?
Date: Mon, 29 Sep 2014 14:47:02 -0600
[Message part 3 (text/plain, inline)]
tag 18585 notabug
thanks

On 09/29/2014 07:25 AM, Schapovalov, Sebastian wrote:
> Hello, I was testing one parameter in my .sh and realised that the wc command return a different value that I was expected.  I send you a couple examples.
> 
> I have to validate a celular telephone number (in Argentina), so, it has to be a 10 chars parameter.
> 
> sarasa() -- seba > echo 1029384756 | wc -c
> 11

Classic user mistake.  'echo' outputs a trailing newline, which IS a
character,

> sarasa () -- seba > echo 1029384756 | wc -L
> 10

but does NOT contribute to the length of the longest line.  Try
comparing these two commands

echo 1029384756 | oc -tx1z
printf 1029384756 | oc -tx1z

to see what I mean.

I'm closing this as not a bug, but feel free to ask further questions.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]
[Message part 5 (message/rfc822, inline)]
From: "Schapovalov, Sebastian" <sebastian.schapovalov <at> telefonica.com>
To: "bug-coreutils <at> gnu.org" <bug-coreutils <at> gnu.org>
Subject: Bad count in WC command?  
Date: Mon, 29 Sep 2014 13:25:40 +0000
[Message part 6 (text/plain, inline)]
Hello, I was testing one parameter in my .sh and realised that the wc command return a different value that I was expected.  I send you a couple examples.

I have to validate a celular telephone number (in Argentina), so, it has to be a 10 chars parameter.

sarasa() -- seba > echo 1029384756 | wc -c
11

sarasa () -- seba > echo "1029384756" | wc -c
11

sarasa () -- seba > echo 1029384756 | wc -m
11

sarasa () -- seba > echo "1029384756" | wc -m
11

I got the correct value only with the “–L” option.

sarasa () -- seba > echo 1029384756 | wc -L
10

sarasa () -- seba > echo "1029384756" | wc -L
10

I tested it (with same output) in:

Linux 2.6.9-78.0.22.ELlargesmp #1 SMP Fri Apr 24 12:59:13 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
and
Linux 3.2.0-29-generic-pae #46-Ubuntu SMP Fri Jul 27 17:25:43 UTC 2012 i686 i686 i386 GNU/Linux


Regards! (and excuse me for my bad english)

Seba

________________________________

Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.

The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.

Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição
[Message part 7 (text/html, inline)]

This bug report was last modified 10 years and 293 days ago.

Previous Next


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