Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux head command

Linux head command

Linux Command Reference Linux Command Reference

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:

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 Linux Command Reference