[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18585: Bad count in WC command?

From: Eric Blake
Subject: bug#18585: Bad count in WC command?
Date: Mon, 29 Sep 2014 14:47:02 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1

tag 18585 notabug

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

> 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

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]