The head command
Print the first lines of files. Prints the first 10 lines of each file, or of what is piped into it. With more than one file, each part starts with a ==> name <== header.
Usage
head [OPTION]... [FILE]...
Options
| -n N, --lines=N | the first N lines instead of 10 |
|---|---|
| -n -N | everything except the last N lines |
| -N | short for -n N |
Examples
head notes.txtThe first 10 lineshead -n 3 notes.txtThe first 3 linessort scores.txt | head -n 5The five lowest
Learn it step by step
Related commands
learner@sandbox: ~bash (practice)
Note: Try head here: your home directory has sample files. Press Try beside an example, or type your own.
Enter runs · Tab completes names · ↑ ↓ step through history · Ctrl+L clears · type help for every command
A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.