wc(1) wc(1)
NAME
wc - word, character and line count
SYNOPSIS
wc [option ...] [file ...]
DESCRIPTION
wc counts the number of lines, words and bytes, or characters con-
tained in files and writes the results to standard output.
OPTIONS
No option specified:
wc outputs three numeric values for the number of lines, words,
and bytes.
-c wc outputs the number of bytes. Must not be combined with -m.
-l wc reports the number of lines, based on the number of newline
characters counted by wc.
-m wc outputs the number of characters, including blanks, tabs, and
newline characters. Must not be combined with -c.
-w wc reports the number of words. A word is defined as a non-empty
string delimited by whitespace characters. Whitespace characters
are blanks, tabs and newline characters.
-- If file begins with a dash (-), the end of the command-line
options must be marked with --.
file Name of the file whose lines, words and bytes, or characters are
to be counted. The file name will be printed along with the
counts.
More than one file may be specified. If several files are named,
wc prints an additional line with a grand total of the individual
values for all specified files.
file not specified:
wc reads from standard input.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed.
LCCTYPE defines which characters are treated as whitespace charac-
ters.
If LCMESSAGES or LCCTYPE is undefined or is defined as the null
string, it defaults to the value of LANG. If LANG is likewise unde-
fined or null, the system acts as if it were not internationalized.
Page 1 Reliant UNIX 5.44 Printed 11/98
wc(1) wc(1)
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
If any of the locale variables has an invalid value, the system acts
as if none of the variables were set.
EXAMPLES
Example 1
Listing line, word, and character counts for the files logic, plan and
rem.
$ wc logic plan rem
27 139 1077 logic
5 15 140 plan
3 6 51 rem
35 160 1268 total
Example 2
Counting the number of files in the current directory.
$ ls | wc -l
31
Example 3
Checking the number of users working on the system.
$ who | wc -l
6
Example 4
Counting the number of unique words in a file.
$ cat file | sed 's/<blank><blank>*/\
> /g' | sort -u | wc -l
Explanation:
sed creates a list of all words in file by replacing one or more
blanks by newline characters. sort -u sorts this list, removing all
repetitions. wc -l then counts the lines in this list and prints the
total.
SEE ALSO
cksum(1).
Page 2 Reliant UNIX 5.44 Printed 11/98