Name

wc

Synopsis

wc [options] [files]

Prints byte, character, word, and line counts for each file. Prints a total line for multiple files. If no files are given, reads standard input. See other examples under ls and sort .

Options

-c

Print byte count only.

-l

Print line count only.

-m

Print character count only.

-w

Print word count only.

Examples

Count the number of users logged in:

$ who | wc -l

Count the words in three essay files:

$ wc -w essay.[123]

Count lines in the file named by variable $file (don’t display the filename):

$ wc -l < $file

Get Mac OS X Tiger in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.