man.lsPlain-English help for Unix commands

head Show the first lines of a file

Prints the first part of a file, ten lines by default. Use it to peek at a large file, check a CSV header, or take the top few results from another command.

Synopsis

head [-n count | -c bytes] [file ...]

Common options

Option or formWhat it does
-n countPrint the first count lines instead of 10. Also written -n5 or, as a shorthand, -5
-c bytesPrint the first bytes bytes instead of lines. A multi-byte character can be cut in half
-5Old shorthand for -n 5. Any number works.
-n -countGNU only: print everything except the last count lines. macOS head rejects it with an illegal line count error
-qGNU only: never print the ==> name <== header when given several files. macOS head has no -q
-vGNU only: always print the file name header, even for one file. macOS head has no -v

Examples

First 10 lines of a file
head notes.txt
Only the first 3 lines
head -n 3 notes.txt
alpha
beta error
gamma
Show the header row of a CSV file
head -n 1 data.csv
name,team,score
Peek at several files at once
head -n 2 notes.txt app.log
==> notes.txt <==
alpha
beta error

==> app.log <==
2026-01-01 INFO start
2026-01-01 ERROR failed to open
Take the top two lines of another command's output
sort words.txt | uniq -c | sort -rn | head -n 2
Print only line 3 of a file
head -n 3 notes.txt | tail -n 1
gamma

Notes

See also

Last reviewed 2026-10-07.