wc

Count lines, words and bytes

What it does

wc (word count) prints three numbers: lines, words and bytes. -l keeps just the lines, -w the words, -c the bytes.

wc -l is the one you need most: how many rows in a CSV, lines in a log or files in a list. It fits at the end of a pipe: ls | wc -l counts the files in a folder.

Syntax

wc <file>
wc -l <file>

Examples

Related commands

Practise · All commands