wc — count lines, words, characters and bytes
SYNOPSIS
wc [-l] [-w] [-c] [-m] [-L] <file...> wc (count piped input)
DESCRIPTION
Counts newlines, words and bytes in each file, printing one row per file plus a total row when several are given. With no file (or -), wc counts what is piped into it — e.g. ls | wc -l. With no flag, it prints lines, words and bytes (in that order).
OPTIONS
-l count lines (newlines) -w count words (whitespace-separated) -c count bytes (UTF-8) -m count characters (code points) -L length of the longest line
- count standard input (the piped text)
Single-letter flags can be combined, e.g. wc -lw file.
USE CASES
- count the words of an article, an essay or a cover letter before sending it, or check a text against a word limit;
- count the lines of a file or of any command's output: ls | wc -l;
- check a text's size in bytes (-c) versus characters (-m): they differ as soon as it contains accents or emoji, which matters for size-limited fields (SMS, tweets, database columns).
NOTES
A word is a run of non-blank characters, as in the Unix wc. Everything is counted in your browser: the text is never sent anywhere.
EXAMPLES
wc about.md wc -l about.md contact.md ls | wc -l echo "hello world" | wc -w