[Previous] [Contents] [Next]

wc

Word, line, and byte count (POSIX)

Syntax:

wc [-clw] [-ht] [file...]

Options:

-c
Write to the standard output the number of bytes in each input file.
-h
(QNX extension) Display headers.
-l
("el") Write to the standard output the number of lines in each input file.
-t
(QNX extension) Don't display totals.
-w
Write to the standard output the number of words in each input file.
file
The pathname of an input file. If no files are specified, the standard input is used.

Description:

For each input file, the wc utility counts lines, words, and characters (bytes) in the file and writes the results to the standard output.

If you don't specify any options, wc writes counts of lines, words and characters, in that order. If you specify one or more of the options -l, -w, or -c, the wc utility reports only the information selected for the specified options. The order in which you specify the options -l, -w and -c determines the order in which the number of lines, words, or bytes are written.

If you specify more than one input file, wc also writes a total count for all named files, for each option.

The utility considers a word to be a string of characters delimited by white space.

To get its line count, wc counts newline characters. If the last line of a file lacks the newline terminator, it isn't counted.

Files:

The input files are text files.

Exit status:

0
Successful completion.
>0
An error occurred.

[Previous] [Contents] [Next]