Privacy Policy
© 2026 linux101.dev

wc Command Cheatsheet

The wc (word count) command is used to count lines, words, characters, and bytes in files or from standard input. It is a quick way to inspect file size and text statistics.

Common Syntax

The most common usage prints line, word, and byte counts.

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

Without options, wc outputs three columns: lines, words, and bytes.

Common Count Options

You can specify exactly what type of count to display.

OptionDescriptionExample
-lCount lines only.wc -l notes.txt
-wCount words only.wc -w article.txt
-cCount bytes only.wc -c data.bin
-mCount characters only.wc -m utf8.txt

Useful Output Options

OptionDescriptionExample
-LPrint the length of the longest line.wc -L report.txt
--files0-from=FRead input file names terminated by NUL from file F.wc -l --files0-from=list.txt
--total=WHENControl when to print a total line (GNU wc behavior).wc --total=only *.log

Using wc with Pipelines

wc is frequently used in command pipelines to summarize output from other tools.

# Count how many .log files exist in the current directory
ls -1 *.log 2>/dev/null | wc -l
Desktop Ad Placeholder