How to Count Lines, Words, and Characters in Linux (wc)
wc (word count) counts the number of lines, words, and characters (or bytes) in a file or piped input.
Published October 2, 2026
wc (word count) counts the number of lines, words, and characters (or bytes) in a file or piped input.
Key points
- wc -l counts only lines — one of the most common uses, e.g. counting how many results a command produced
- wc -w counts words; wc -c counts bytes
- Commonly combined with a pipe: grep -c isn't always available, so cat file | grep pattern | wc -l is a common substitute
Example
cat access.log | wc -l