Why does wc increase character count by 1 ?
mfv
mfv at bway.net
Sat Sep 9 18:22:24 UTC 2017
> On Sat, 2017-09-09 at 18:10 Manish Jain <bourne.identity at 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 at freebsd.org mailing list
>https://lists.freebsd.org/mailman/listinfo/freebsd-questions
>To unsubscribe, send any mail to
>"freebsd-questions-unsubscribe at 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
More information about the freebsd-questions
mailing list