O'Reilly logo

Mac OS X Tiger in a Nutshell by Jason McIntosh, Chuck Toporek, Chris Stone, Andy Lester

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required