Linux Commands | File Management | head Print File Contents from the Top
head Command
The head command prints file contents from the top. By default, it prints the first 10 lines.
Syntax
head (-number) [file name]
Option
-1: Enter the number of lines you want to display.
head Command Examples
Example 1
Print the first 5 lines of /etc/passwd.
head -5 /etc/passwd
Example 2
Print the first 10 lines of /etc/passwd and display line numbers on the left.
head /etc/passwd | cat -n