Bash 5 reference · Text and System Tools
wc (Linux command)
Count lines, words, characters and bytes in files or input; wc -l is the usual way to count lines or results.
Bash 5
Syntax
wc [-l] [-w] [-c] [-m] [FILE...]
Parameters
| Parameter | Description |
|---|---|
-l |
Lines. |
-w |
Words. |
-c / -m |
Bytes / characters. |
Examples
printf 'a b\nc\n' > f.txt
wc -l f.txt
wc -w < f.txt
Output
2 f.txt 3
Run this on your computer — see “Get Started” for setup.
printf 'café' | wc -c
printf 'café' | wc -m
Output
5 4
Run this on your computer — see “Get Started” for setup.
Related
head and tail· Show the first or last lines of files, skip headers, and follow growing log files with tail -f.grep· Search files or input for lines matching a pattern, with options for case, counts, context, recursion and regex.- Bash Viewing Files · tutorial