wc

The command that counts lines, words and bytes in its input; -l gives only the line count.

In more detail

wc -l counts lines, wc -w words and wc -c bytes. When it reads from standard input, as in wc -l < file, it prints just the number, while wc -l file adds the file name. Some versions pad the number with spaces.

Examples

wc -l < names.txt
git -C fixture tag -l 'deploy-*' | wc -l  # counts deployment tags
git -C fixture tag -l 'deploy-*' | wc -l
wc -c .git/refs/heads/feature prints 41: a 40-character ID and a new line.

Related terms

Taught in

References

Certification courses