How does the wc -c in linux work?

Pankaj Mahato picture Pankaj Mahato · May 6, 2014 · Viewed 13k times · Source

Why the number of characters is 4?

echo abc|wc -c

Output

4

The output should be 3, because the number of characters is 3.

Answer

ismail picture ismail · May 6, 2014

Its also counting the newline, try

[~]> echo -n abc|wc -c
3

-n tells the echo not to print a newline.