Linux Common commands: Head command

Source: Internet
Author: User

Head and tail are as simple as their name, which is used to display the beginning or end of a number of chunks of text, the head is used to display the beginning of the file to the standard output, and tail to see the end of the file.

1. Command format:

Head [parameters] ... [File] ...

2. Command function:

The head is used to display the beginning of the file to the standard output, and the default head command prints the first 10 lines of its corresponding file.

3. Command parameters:

-Q Hide file names

-V Show file name

-c< bytes > Display bytes

-n< rows > rows displayed

4. Usage examples:

Example 1: Display the first n rows of a file

Command:

Head-n 5 Log2014.log

Output:

[Email protected] test]#CatLog2014.log the- on the- Geneva the-Geneva the-Geneva the- to the- . the- - the- , the- the the-Ten the- One the- A==============================[email protected] test]#Head-N5Log2014.log the- on the- Geneva the-Geneva the-Geneva the- to[Email protected] test]#

Example 2: Displaying the first n bytes of a file

Command:

Head-c Log2014.log

Output:

Head  - Log2014.log -[Email protected] test]#

Example 3: The file's contents except the last N bytes

Command:

Head-c -32 Log2014.log

Output:

[Email protected] test]#Head-C- +Log2014.log the- on the- Geneva the-Geneva the-Geneva the- to the- . the- - the- , the- the the-Ten the- One the- A[Email protected] test]#

Example 4: Output file except the last n rows of the entire content

Command:

Head-n-6 Log2014.log

Output:

Head -N-6  log2014.log---- Geneva ----07 [email protected] test]#

Linux Common commands: Head command

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.