DELAPARRA
Index
Color
NL
Category: CLI commands

head

Explained by Updated

What is head?

head: Head — Show the first N lines of a file (default 10). head shows the first lines of a file or command output, ten by default. head -n 20 export.csv shows the first twenty lines. It is a quick way to peek at large files without opening them completely. Checking the column headers of a CSV export, the start of a log, or the first records of a data dump takes a second.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about head

What should you keep in mind with head?

Its counterpart tail shows the end of a file, and tail -f follows new lines as they are written, which is the classic way to watch a log live. In pipelines, head is useful for limiting output, as in sort access.log | uniq -c | sort -rn | head to see the ten most frequent lines. It also stops reading early, so it is fast even on huge files.

At a glance

CategoryCLI commands
Explained by
Updated

More CLI commands terms

All terms starting with H

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.