The wc
Command
The wc
(word count) command can be used to display
line, word, byte or character counts for a text file. This command is
useful when trying to determine characteristics of a file or when
comparing two files. Using wc
without options will give a line, word, and byte count of the contents
of the file. Using it with individual options allows you to determine
which of these you would like to see. Figure
lists the options
that are available with the
wc
command.
Like the
head
and
tail
commands,
wc
can be used by itself but is typically used in a command
line containing several commands in a pipeline when you want to count
the output. This will be covered later in the course.
| Command Format: |
| wc [options]
filename(s) |
Figure
shows examples of its
use. In the first example, the wc
command by itself indicates
that the file dante contains 33 lines, 223 words and 1320 bytes. The
second example shows the line count.
|