wc.1 (2249B)
- .\" utils-std: Collection of commonly available Unix tools
- .\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- .\" SPDX-License-Identifier: MPL-2.0
- .Dd 2024-04-24
- .Dt WC 1
- .Os
- .Sh NAME
- .Nm wc
- .Nd Count lines, words, bytes/characters
- .Sh SYNOPSIS
- .Nm
- .Op Fl c Ns | Ns Fl m
- .Op Fl lw
- .Op Ar file...
- .Sh DESCRIPTION
- .Nm
- reads each given
- .Ar file
- and by default report their numbers of newlines, words and bytes.
- If no
- .Ar file
- is given, then
- .Nm
- reads from standard input.
- .Pp
- A word is defined as a non-empty string delimited by whitespace,
- some other implementation choose to additionally exclude
- non-printable characters.
- .Sh OPTIONS
- .Bl -tag -width __
- .It Fl c
- Explicitly use single-byte mode, and write the number of bytes in each
- .Ar file .
- .It Fl l
- Write the number of newlines in each
- .Ar file .
- .It Fl m
- Switch to multi-byte mode, and write the number of codepoints in each
- .Ar file .
- The encoding is dependent on the
- .Xr locale 1
- environment variables.
- .Pp
- Note that while codepoints are often close enough to characters,
- some characters use multiple codepoints,
- plus by design
- .Nm
- cannot consider glyphs due to lacking rendering.
- .Pp
- For example with decomposed é (e with acute diacritic) in a
- .Ql C.UTF-8
- locale:
- .Bd -literal -compact
- $ printf '\\145\\314\\201\\n'
- é
- $ printf '\\145\\314\\201' | wc -c
- 3
- $ printf '\\145\\314\\201' | wc -m
- 2
- .Ed
- .It Fl w
- Write the number of words in each
- .Ar file .
- .El
- .Pp
- If any option is specified,
- .Nm
- reports only the requested information, without their ordering
- changing output formatting.
- The default is equivalent to
- .Cm wc
- .Fl clw .
- .Sh ENVIRONMENT VARIABLES
- See
- .Xr locale 1 .
- .Sh STDOUT
- By default the standard output reports each file in the form:
- .Bd -literal
- "%d %d %d %s", <newlines>, <words>, <bytes>, <file>
- .Ed
- .Pp
- Similarly to GNU and BusyBox, this implementation also makes sure
- to not print trailing whitespace, which would have to be trimmed
- in most scripts.
- .Pp
- If more than one
- .Ar file
- is given, a final line is printed with "total" instead of a pathname.
- .Sh EXIT STATUS
- .Ex -std
- .Sh STANDARDS
- .Nm
- should be compliant with the
- IEEE Std 1003.1-2024 (“POSIX.1”)
- specification.
- .Sh AUTHORS
- .An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me