wc

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

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

wc (word count) counts newlines, words, characters, and bytes in files or stdin. Invaluable for quick data validation — checking how many records are in a file, confirming a log has expected line counts, or measuring output size.

Common flags
FlagMeaning
-l --linesCount lines only
-w --wordsCount words only
-c --bytesCount bytes only
-m --charsCount characters only
Examples
wc -l /etc/passwdCount number of user accounts · explain & risk-check →
cat access.log | wc -lCount total log entries · explain & risk-check →
ls *.yaml | wc -lCount YAML files in current directory · explain & risk-check →
wc -c deployment.yamlCheck file size in bytes · explain & risk-check →
Pro tip

Use `grep -c 'pattern' file` instead of `grep 'pattern' file | wc -l` — it's faster and more efficient for counting matching lines.

Related
grep awk sort
Open the full explainer →More in Text Processing

Reference text is hand-written and may be incomplete — check man wc for your version. Test destructive commands on a non-production system first.