Concise Linux Command Line notes: Head

Source: Internet
Author: User
ArticleDirectory
    • Option
    • Note:
    • Example

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.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.