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
Normally, wc's output format defaults to the format
of the first file it displays unless the
If you did not specify any options, wc produces the following output:
newline_count word_count byte_count filename
When you specify options, wc displays only the selected
counts in the same order as the default output. If you specify
A word is considered to be a character or characters delimited by white space.
-coption of wc counts bytes, not characters. This is a change from previous versions of wc, dictated by the POSIX.2 standard which provides the -moption 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.
displays a byte count. You cannot specify this option with
displays a newline count.
displays a character count. You cannot specify this option with
-c. -U[[[ c][ lb8oa]][ p[ lb8oa]]]
specifies the input format of any file missing the initial multiple-byte marker, the output format produced, or both.
cis specified, the specifiers that follow it apply to the input consumed.
pis specified, the specifiers that follow it apply to the output produced.
cnor pare specified, the remaining -Uspecifiers apply to the input consumed.
cand pare specified, the remaining -Uarguments apply to both input and output.
The remaining specifiers indicate the format of the characters read from input or written to output (as determined by
cand p): llittle-endian 16-bit wide characters bbig-endian 16-bit wide characters 8UTF-8 characters aASCII characters from the ANSI code page oASCII characters from the OEM code page
When multiple format specifiers can be associated with either c or p, the last appropriate one given on the command for each of c and p is used. For example:
is the same as:
When a p specifier is given without a c specifier and format specifiers are given before the p specifier, those format specifiers apply to the input. For example:
is the same as:
When c or p is specified with no format specifies, little endian 16-bit wide characters are used by default for either input or output, as appropriate.
As an alternative to specifying formats for both input and output with the same
-Uoption, you can specify the -Uoption multiple times. For example, the following are identical: -Uca -Upb -Ucapb
-Uspecifiers are actually case-insensitive. For example, the following are all identical in their behavior: -Ucl -UcL -UCl -UCL -w
displays a word count.
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.
Possible exit status values are:
Failure because of an inability to open the input file.
Failure because of an invalid command line option.
POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 2000. Windows XP. Windows Server 2003. Windows Vista. Windows 7. Windows Server 2008. Windows 8. Windows Server 2012.
MKS Toolkit for Power Users
MKS Toolkit for System Administrators
MKS Toolkit for Developers
MKS Toolkit for Interoperability
MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition
MKS Toolkit 9.5 Documentation Build 3.