wc

Official Description

Counts the lines, words, characters, and bytes in a file.

Syntax

wc [-c  | -m] [-lw] [file...]

Options

-c counts bytes.

-l counts lines.

-m counts characters.

-w counts words.

Oddities

Words are separated by whitespace.

Example

$ wc buzz*                   # Lines, words, chars
       6       9      47 buzz
      11      18      90 buzz1
       6       9      47 buzz10
      16      31     152 buzz2
      12      22     116 buzz3
      16      33     165 buzz4
      67     122     617 total
$
$ wc -l buzz                 # Lines only
       6 buzz
$
$ ps laxw | wc –l            # Useful in pipes
      42
$
				

Get Korn Shell Programming by Example 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.