head, tail, wc and nl — Looking Before You Process
A log file can have two million lines. Opening it in an editor is slow, and printing all of it floods the terminal. Before doing anything clever with a file, Asha takes a quick look: the top, the bottom, how big it is, and where each line sits. Four small tools do this.
The rule
Peek before you process: head, tail, count, number.
head shows the first lines, 10 by default:
$ head -n 2 harvest.csv
date,crop,kg,picker
2026-06-01,tomato,3.5,ashatail shows the last lines:
$ tail -n 1 harvest.csv
2026-06-04,basil,0.6,ashaTwo tail tricks are worth memorising:
tail -n +2means "start from line 2", so it prints everything except the header. That's perfect for CSV files.tail -ffollows a growing file and prints new lines as they're added. Press Ctrl+C to stop. It's the standard way to watch a log live.
wc (word count) counts lines, words and bytes:
$ wc harvest.csv
7 7 181 harvest.csv
$ wc -l harvest.csv
7 harvest.csv-l is lines, -w is words (runs of text separated by spaces) and -c is bytes. Each CSV row has no spaces, so here every line counts as one word.
nl numbers lines:
$ nl -ba notes.txtBy default nl skips numbering blank lines. -ba ("body: all") numbers every line. cat -n does much the same.
All four read stdin when you don't give a file, so they fit neatly into pipes.