Why does wc increase character count by 1 ?
Matthias Apitz
guru at unixarea.de
Sat Sep 9 19:26:30 UTC 2017
El día sábado, septiembre 09, 2017 a las 06:10:41p. m. +0000, Manish Jain escribió:
> Hi,
>
> echo "abc 123" | wc -c
>
> I would expect wc to output 7, but actually I get 8.
>
> Indeed, I see similar behaviour with 'echo | wc -c'
> This should produce 0, but I get 1
>
> What might be the problem ? Thanks for any tips.
> Manish Jain
$ echo "abc 123" | od -c
0000000 a b c 1 2 3 \n
0000010
As you see, echo adds one by of \n
matthias
--
Matthias Apitz, ✉ guru at unixarea.de, ⌂ http://www.unixarea.de/ ☎ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
8. Mai 1945: Wer nicht feiert hat den Krieg verloren.
8 de mayo de 1945: Quien no festeja perdió la Guerra.
May 8, 1945: Who does not celebrate lost the War.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20170909/21f4b298/attachment.sig>
More information about the freebsd-questions
mailing list