wc

Command

wc counts the number of newlines, words, characters and
bytes in text files.
If you specify multiple files, wc produces counts for
each file, plus totals for all files.

Besides normal ASCII text files, wc also works on UTF-8
files and 16-bit wide Unicode files. Such files normally begin with a
multiple-byte marker indicating whether the file's contents are Unicod
big-endian, Unicode little-endian, or UTF-8. Such files are detected
automatically by wc; however, when the multiple-byte marker
is missing, you can use the -U option or the
TK_STDIO_DEFAULT_INPUT_FORMAT/TK_STDIO_DEFAULT_OUTPUT_FORMAT
environment variables to treat any file as a Unicode or UTF-8 file.

Normally, wc's output format defaults to the format
of the first file it displays unless the -U option
or the TK_STDIO_DEFAULT_OUTPUT_FORMAT environment variable
is used to override the output format.
For more details on this and other Unicode-related file handling issues
see the unicode reference page.

If you did not specify any options, wc produces the
following output:

newline_countword_countbyte_countfilename

When you specify options, wc displays only the selected
counts in the same order as the default output. If you specify
-m, the character count replaces the byte count.
For example, -cw displays the word count followed by
the byte count and the file name and -ml displays the
newline count followed by the character count and file name.

A word is considered to be a character or characters delimited by
white space.

Note:

The -c option of wc counts bytes,
not characters. This is a change from previous versions of
wc, dictated by the POSIX.2 standard which provides
the -m option to count characters.
If you have a file containing multibyte characters, the byte
count is higher than the character count.
On Windows systems, a line of a text file is often delimited by the sequence
carriage return/linefeed.
Since wc views its input as text,
this sequence is counted as a single newline byte.

Sets the default input format for files that don't have the initial
multibyte marker.
The value must be one of those listed in the
File Character Formats section of the
unicode reference page.

TK_STDIO_DEFAULT_OUTPUT_FORMAT

Sets the default output format.
Normally the format of the first file read is used as the default output
format.
The value must be one of those listed in the
File Character Formats section of the
unicode reference page.