[Shell command] Count characters with wc

Created on November 30, 2026

Pass -m to wc to count characters. In a UTF-8 locale, this example counts five characters in the Japanese greeting. printf '%s' avoids adding a newline to the input.

printf '%s' 'こんにちは' | wc -m
5

Use wc -c to count bytes.

Shell command