One Linux command per day-head

Source: Internet
Author: User

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:

    1. 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

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.