wc command (Linux / bash / sh / zsh)
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 / option | Meaning |
|---|---|
| -l | Count newline characters. |
| -w | Count words. |
| -c | Count bytes. |
| -m | Count characters. |
| -L | Report 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.
Related commands
- uniqReport or remove adjacent duplicate lines.
- grepSearch text for lines matching a pattern.
- findWalk directory trees and select entries using tests and actions.
- Where-ObjectFilter pipeline objects by property values or a script block predicate.
- catConcatenate files and write their contents to standard output.
- Get-ContentRead file content or provider data as a stream of objects.
- echoWrite arguments and shell-expanded values to standard output.
- echoDisplay text or control command echoing in a batch script.
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.