Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)

User Commands (v - z) wc(1)
NAME
wc - Counts lines, words, characters, and bytes
SYNOPSIS
wc [-c | -k | -m][-lw][le ...]
FLAGS
-c Counts bytes.
-k Counts characters.
-m Counts characters.
-l Counts lines.
-w Counts words.
DESCRIPTION
The wc command counts the lines, words, characters, and bytes in a le, or in the standard input
le if you do not specify any les, and writes the results to the standard output le. It also keeps
a total count for all named les.
A word is dened as a nonzero-length string of characters delimited by spaces, tabs, or newline
characters. A line is dened as zero or more characters followed by a newline character.
The wc command counts lines, words, and bytes by default; use the appropriate ags to limit wc
output. Specifying wc without ags is the equivalent of specifying wc -lwc.
The order in which the counts appear in the output line matches the order in which the ags are
entered on the command line. (If you do not specify any ags, the order is lines, words, bytes.)
When you specify more than one le, wc displays the name of the le along with the counts.
EXAMPLES
1. To display the number of lines, words, and bytes in the le text,enter:
wc text
This command results in the following output:
27 185 722 text
The numbers 27, 185, and 722 are the number of lines, words, and bytes, respectively, in
the le text.
2. To display only one or two of the three counts, or to display the counts you want in a par-
ticular order, include the appropriate ags in the order you want. For example, the fol-
lowing command displays only byte and line counts:
wc -cl text
722 27 text
3. To count lines, words, and bytes in more than one le, use wc with more than one input
le or with a lename pattern. For example, the following command can be issued in a
directory containing the les text, text1, and text2:
wc -l text*
27 text
112 text1
5 text2
144 total
527188-004 Hewlett-Packard Company 1025