Why `wc -c` always count 1 more character?

Because newlines are characters too. Tell your text editor to not add one at the end of the file. No, I don't know how.


One way is to tr to delete newlines, then you can count the characters.

Standard behavior:

echo HELLO | wc -m
# result: 6
echo -n HELLO | wc -m
# result: 5

To show the count of newline characters found:

echo HELLO | wc -l
# result: 1
echo -n HELLO | wc -l
# result: 0

Strip the newline character and count characters:

echo HELLO | tr -d '\n' | wc -m
# result: 5

Strip the newline character (and possible returns with \r) and count characters for an input file:

tr -d '\n\r' < input.txt | wc -m