head
See the start of a file or of any command's output: the first 10 lines, or exactly as many as you want.
>_ Try it: a simulated Linux, right herenothing runs on your computer
Loading the terminal…
Examples
-
head app.log -
head -n 3 app.log -
head -n 1 users.csv -
ls /etc | head -n 3 -
head -n 2 app.log users.csv
How it works
head FILE prints the first 10 lines of a file — handy for a quick look at a big log or a CSV without scrolling through all of it.
Choose how many with -n: head -n 3 app.log. It also reads a pipe, so ls /etc | head -n 3 shows just the first three names.
Syntax
head [-n LINES] [FILE]...
Options
| Option | What it does |
|---|---|
-n N | show N lines instead of 10 |
-N | the short form: head -3 is head -n 3 |
Good to know
headshows the start,tailthe end: together they cover most "what is in this file?" questions.head -n 1 users.csvis the quickest way to see which columns a CSV has.