Skip to content

wc command

Count lines, words and bytes.

On this page

Syntax

wc [options] [file…]

Provided by the coreutils package. Run man wc for the full manual.

Common options

OptionWhat it does
-lCount lines
-wCount words
-cCount bytes
-mCount characters
-LLength of the longest line

Examples

  1. Count lines in a file

    wc -l access.log
  2. Count words

    wc -w essay.txt
  3. Count files in a directory

    ls -1 | wc -l
  4. Count matching lines

    grep "ERROR" app.log | wc -l
  5. Lines in every .py file, with a total

    wc -l *.py

wc guides

← All Linux commands · Suggest a fix

Back to top