Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Sep 2017 20:14:38 +0200
From:      Matthias Apitz <guru@unixarea.de>
To:        Manish Jain <bourne.identity@hotmail.com>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   Re: Why does wc increase character count by 1 ?
Message-ID:  <20170909181438.GA2868@c720-r314251>
In-Reply-To: <VI1PR02MB12007715EC3BFAF626325B4EF66A0@VI1PR02MB1200.eurprd02.prod.outlook.com>
References:  <VI1PR02MB12007715EC3BFAF626325B4EF66A0@VI1PR02MB1200.eurprd02.prod.outlook.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--AqsLC8rIMeq19msA
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

El d=C3=ADa s=C3=A1bado, septiembre 09, 2017 a las 06:10:41p. m. +0000, Man=
ish Jain escribi=C3=B3:

> Hi,
>=20
> echo "abc 123" | wc -c
>=20
> I would expect wc to output 7, but actually I get 8.
>=20
> Indeed, I see similar behaviour with 'echo | wc -c'
> This should produce 0, but I get 1
>=20
> 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

--=20
Matthias Apitz, =E2=9C=89 guru@unixarea.de, =E2=8C=82 http://www.unixarea.d=
e/  =E2=98=8E +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=C3=B3 la Guerra.
May 8, 1945: Who does not celebrate lost the War.

--AqsLC8rIMeq19msA
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEXmn7rBYYViyzy/vBR8z35Hb+nREFAlm0L4sACgkQR8z35Hb+
nRGzKA/9EcBufrtVWGUtDA3q5Q0BwNKYNXgeKG4iSXuNHTT8uS+qw4OcPMuo5yda
tiZrAFUcnhFjLxIR0icaMSLsoh6o0UYldiv2xi6tAdRT8k+RWR196eX8SBcwwkhZ
2WALd6zZshPgsWNiLxuyNQAXmiXjsKHs8/lPvzGx/249XbUwMjZ8bEb0naboNKYJ
7fBz885rVMNpTpwejP6bALAGAZOKva/wKN50bRCJEgw9cOnDKojvQaU6+W1wBPIg
1yXCnf5SGeEiaacM7+XSb6IupjAHC9UObixoRqou6MDfQ9bOKw8e/Jwfx76C+GLF
iFdDjniPFiNUUTSKw7jQetoUOFAMwh4psidzYPpqzqI8vszhvuscTwezHnCzEtT9
PbJbvnlhY/DxoKCrFiZoS2+tLcLr5nLTgsWe+VE3hK2ntLhg5g0uVNDmQp3ZPq+a
wkqAev+weoMOUx0zrXwtb284rshSBmEfSToOUtO5m7J7RlvmZUkn7jZSGOmL/kJP
PDOKQVwBqLrrZ2F09vXjvIdqPQ3DtEsms9s3TjFYKdnBuE/jRSk6V6x+6dvEotkq
xQA+GokxU1RDQ1CC82/zQ3sKSrDKghMm2tjJoonD0BJC95c4dhxxC7znCh3C1E4s
su21lUfxfJiqC4hWRVhLmn+PhI/JOfK8WZrcW/wRhnj/aFy4ycA=
=tZu4
-----END PGP SIGNATURE-----

--AqsLC8rIMeq19msA--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170909181438.GA2868>