Linux tricks, one-liners & shell magic
← Back to all tricks
Count lines / words / bytes in a file

wc is the Swiss Army knife for file statistics. Combine flags or chain with other commands.

bash
$ wc -l file.txt # lines wc -w file.txt # words wc -c file.txt # bytes # Count non-empty lines: grep -c . file.txt # Total lines across multiple files: wc -l *.log | tail -1
wordcounter2026-04-19
Delete this trick? This cannot be undone.