Head and tail are as simple as their names. Head, used to display the beginning of the file or the specified area, head to get the beginning of the file to the standard output, and tail is used to get the file tail information to the standard output.
Command format:
Head [option] filename
Command parameters:
-C: Specifies the number of characters to display.
-N: Specifies the number of rows to display, without specifying the first 10 rows of the file with the-n default.
-Q: Hides the file name.
-V: Displays the file name.
Command instance:
Displays the first 10 lines of the file.
Command: Head test.txt #不加参数, the default output file header 10 lines.
Output:
[Email protected] ~]# head test.txt 12345678910[[email protected] ~]#
2. Displays the header 15 lines of the file.
Command: Head-n test.txt
Output:
[Email protected] ~]# head-n test.txt 123456789101112131415[[email protected] ~]#
3. Display the first 20 characters of a file
Command: Head-c test.txt
Output: #每行行尾存在一个换行符, can be seen in the VI command mode, said with the set list.
[Email protected] ~]# head-c test.txt 12345678910[[email protected] ~]#
One Linux command per day-head