Reading files
The wc command
Counts lines, words and characters. With pipes it is a result counter.
Syntax
wc [-l|-w|-c] <archivo>Most useful options
-lCounts lines-wCounts words-cCounts charactersCopy-ready examples
$ wc -l Documentos/tareas.txtHow many lines it has$ grep -r bash . | wc -lHow many matches there areYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- With no options it prints three numbers in a row: lines, words and characters.
FAQ
Why does it give three numbers?
Because it counts lines, words and characters. Choose with -l, -w or -c.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course