Skip to main content

Command referencewc

wc command (Linux / bash / sh / zsh)

Linuxbashshzshtextbeginner

What it does

Count lines, words, bytes, or characters in input. When people search for the wc command linux count, they usually want wc's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Count lines, words, bytes, or characters in input.

Syntax

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

Common options

Flag / optionMeaning
-lCount newline characters.
-wCount words.
-cCount bytes.
-mCount characters.
-LReport maximum display width.

Practical examples

Count lines

wc -l access.log

Reports newline count for the log.

Count words

wc -w article.txt

Counts whitespace-delimited words.

Pipeline count

find . -type f | wc -l

Counts paths emitted by find.

Common mistakes

  • Treating line count as record count when the final record lacks a newline.
  • Confusing byte count `-c` with character count `-m` for UTF-8 text.

FAQ

What does wc do in Linux?

Count lines, words, bytes, or characters in input.

How do I use wc from the terminal?

Start with `wc [OPTION]... [FILE]...`, then choose only the options needed for the task.

What is a practical wc example?

Try `wc -l access.log` — Reports newline count for the log.

Can I use wc in a shell script?

Yes. wc works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.