Date: Sat, 9 Sep 2017 14:22:10 -0400 From: mfv <mfv@bway.net> To: freebsd-questions@freebsd.org Subject: Re: Why does wc increase character count by 1 ? Message-ID: <20170909142210.23ed38e2@gecko4> 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
> On Sat, 2017-09-09 at 18:10 Manish Jain <bourne.identity@hotmail.com> > wrote: > >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 >_______________________________________________ >freebsd-questions@freebsd.org mailing list >https://lists.freebsd.org/mailman/listinfo/freebsd-questions >To unsubscribe, send any mail to >"freebsd-questions-unsubscribe@freebsd.org" Hello, It appears to be counting the new line. Use "echo -n" to NOT count the new line. echo "abc 123" | wc produces: 1 2 8 echo -n "abc 123" | wc produces: 0 2 7 Cheers ... Marek
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170909142210.23ed38e2>