wc command
Count lines, words and bytes.
- Text processing
- Package coreutils
- 5 options · 5 examples
Syntax
wc [options] [file…]Provided by the coreutils package. Run man wc for the full manual.
Common options
| Option | What it does |
|---|---|
-l | Count lines |
-w | Count words |
-c | Count bytes |
-m | Count characters |
-L | Length of the longest line |
Examples
Count lines in a file
wc -l access.logCount words
wc -w essay.txtCount files in a directory
ls -1 | wc -lCount matching lines
grep "ERROR" app.log | wc -lLines in every .py file, with a total
wc -l *.py
No example matches. Check the options table or search the guides.
wc guides
- How to Count Lines in a file in Linux Linux Commands · Updated Apr 2025
