Skip to content

The wc command

Count lines, words and bytes. Prints the number of lines, words and bytes in each file (and a total when there is more than one), or in what is piped into it.

Usage

wc [OPTION]... [FILE]...

Options

-l, --linesonly the number of lines
-w, --wordsonly the number of words
-c, --bytesonly the number of bytes
-m, --charsonly the number of characters

Examples

  • wc notes.txtLines, words and bytes
  • wc -l *.txtLines in each text file, plus a total
  • ls | wc -lHow many entries ls printed

Learn it step by step

learner@sandbox: ~bash (practice)
Note: Try wc here: your home directory has sample files. Press Try beside an example, or type your own.

A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.