head

The command that prints the first lines of its input, ten by default or as many as -n says.

In more detail

In a pipeline, head exits once it has enough lines and the command feeding it is then stopped, which is why seq 1 2000000 | head -3 finishes at once. It is the quick way to peek at the start of a large file.

Examples

head -n 3 poem.txt
head -n 1 "$1" reads the subject line of a commit message file.

Related terms

Taught in

References