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