Linux head command
The head command can be used to view the beginning part of a file. A commonly used parameter -n specifies the number of lines to display, defaulting to 10, which means 10 lines are shown.
If you need to view the end part of a file, use the command tail.
Command format:
head [参数] [文件]
Parameters:
- -q Hide the file name
- -v Display the file name
- -c
The number of bytes to display. - -n
The number of lines to display.
Example
To display the first 10 lines of the runoob_notes.log file, enter the following command (with the default -n 10 parameter):
head runoob_notes.log
The above command is equivalent to:
head -n 10 runoon_notes.log
To display the first 5 lines of the notes.log file, enter the following command:
head -n 5 runoob_notes.log
Display the first 20 bytes of the file:
head -c 20 runoob_notes.log
Linux Command Reference