Subject: bug#18585: closed (Re: bug#18585: Bad count in WC command?)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 29 Sep 2014 20:48:04 +0000

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 [email-masked].

-- 
18585: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18585
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#18585: Bad count in WC command?
From: Eric Blake <[email-masked]>
To: "Schapovalov, Sebastian" <[email-masked]>, [email-masked]
Date: Mon, 29 Sep 2014 14:47:02 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

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

Subject: Bad count in WC command?
From: "Schapovalov, Sebastian" <[email-masked]>
To: "[email-masked]" <[email-masked]>
Date: Mon, 29 Sep 2014 13:25:40 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

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