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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

wc [-l] [-w] [-c] [-m] [FILE...]

Parameters

ParameterDescription
-l Lines.
-w Words.
-c / -m Bytes / characters.

Examples

Lines and words
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.

Bytes versus characters
printf 'café' | wc -c
printf 'café' | wc -m

Output

5
4

Run this on your computer — see “Get Started” for setup.

Was this page helpful?