wc on Linux is the fastest sanity check — “how many lines in this log?”, “did my export have the expected row count?”, “is this file empty?” Scripts often store lines=$(wc -l < file) for loops and validation.
Default output
Shows lines, words, and bytes unless you pass flags only.
bashall counts
wc /var/log/syslog

Lines only
-l is the most used flag for scripts and pipelines.
bashlines
wc -l access.log
grep ERROR app.log | wc -l

Bytes and chars
-c bytes; -m characters (locale-aware Unicode).
bashbytes
wc -c image.bin

Pipes and variables
Reading from stdin avoids filename in the count line.
TipUse
wc -l < file so the filename does not appear in the output (clean integer in scripts).
Quick Reference
- Lines:
wc -l file - Pipe:
cmd | wc -l - Script:
lines=$(wc -l < file)
Related tutorials
Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.