Name

wc — stdin  stdout  - file  -- opt  --help  --version

Synopsis

wc [options] [files]

The wc (word count) program prints a count of bytes, words, and lines in a plain text file.[10]

wc myfile
   24      62     428 myfile

This file has 24 lines, 62 whitespace-delimited words, and 428 bytes.

Useful options

-l

Print the line count only.

-w

Print the word count only.

-c

Print the byte count only.

[10] You can run wc on a nontext file, but the concepts of “lines” and “words” will not be well defined.

Get Macintosh Terminal Pocket Guide 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.