ArticleDirectory
Show the file header
Head [Options] [File-list]
Parameters
File-list ToHeadThe list of path names of the displayed files. When multiple files are specified,HeadDisplay the corresponding file name before displaying the first few lines of content of each file
If no file is specified, the head obtains the input from the standard input.
Option
-C n: display the first n Bytes (characters) of the file)
-N indicates the first n rows of the file. You can also use-N to specify the N rows to be displayed.
-Q when multiple file names are specified on the command line, the header cannot be displayed.
Note:
By default, the head will display the first 10 lines of the file.
Example
Original file
$CatDemoline oneline twoline threeline fourline fiveline sixline sevenline eightline nineline tenline eleven
Head
$HeadDemoline oneline twoline threeline fourline fiveline sixline sevenline eightline nineline ten
10 rows are displayed by default.
Head-n
$Head-N4Demoline oneline twoline threeline four
Displays the specified number of rows.
Head-N negative
$Head-N-4Demoline oneline twoline threeline fourline fiveline sixline seven
Show other rows except the last 4 rows
Head-3 multiple files
$Head-3DemoDd==> Demo <=Line oneline twoline three==>Dd<=Line oneline twoline three
Display the first 3 rows of multiple files
Head-C
$Head-C4Demoline $
Display the first 4 characters of the file. Note that the line feed is not used here.