WC(1) | General Commands Manual | WC(1) |
wc
— Count lines,
words, bytes/characters
wc |
[-c |-m ]
[-lw ] [file...] |
wc
reads each given
file and by default report their numbers of newlines,
words and bytes. If no file is given, then
wc
reads from standard input.
A word is defined as a non-empty string delimited by whitespace, some other implementation choose to additionally exclude non-printable characters.
-c
-l
-m
Note that while codepoints are often close enough to
characters, some characters use multiple codepoints, plus by design
wc
cannot consider glyphs due to lacking
rendering.
For example with decomposed é (e with acute diacritic)
in a ‘C.UTF-8
’ locale:
$ printf '\145\314\201\n' é $ printf '\145\314\201' | wc -c 3 $ printf '\145\314\201' | wc -m 2
-w
If any option is specified, wc
reports
only the requested information, without their ordering changing output
formatting. The default is equivalent to wc
-clw
.
See locale(1).
By default the standard output reports each file in the form:
"%d %d %d %s", <newlines>, <words>, <bytes>, <file>
Similarly to GNU and BusyBox, this implementation also makes sure to not print trailing whitespace, which would have to be trimmed in most scripts.
If more than one file is given, a final line is printed with "total" instead of a pathname.
The wc
utility exits 0 on success,
and >0 if an error occurs.
wc
should be compliant with the IEEE Std
1003.1-2024 (“POSIX.1”) specification.
Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
2024-04-24 | Linux 6.6.67-gentoo-x86_64 |