One day a linux base command view file at the beginning of the content head

Source: Internet
Author: User

Head View the contents of the start of a file

1 , command format

Head [option] ... [File] ...


2 , command functions

show file contents, default display of the first 10 lines of the file, you can use [-n] # | [-#] # represents the number of rows displayed, the option specifies how many rows are displayed , if not " file file " when reading input from standard input

3 , common options

- C # : Displays the bytes of the file ( character ) number

- N # : Shows how many lines of a file

4 , command instance

1. Display the first n rows of the file

command: Head-n # File | head-# file

[[Email protected]~]# cat-n Test 1 Askdasjkdhsak 2 hkjasd 3 hakjsd 4 HJAKSD 5 Haksdla SDAs 6 Kasdl[[email protected] ~]# head-n 3 test askdasjkdhsakhkjasdhakjsd[[email protected]~]# head-3 test askda Sjkdhsakhkjasdhakjsd[[email protected]~]#


2. except the last 2 lines do not show all other display

command: head-n-# File

[Email protected]~]# head-n-2 test Askdasjkdhsakhkjasdhakjsdhjaksd[[email protected]~]#


3. Display the first n Characters of a file

command: head-c # File

[Email protected]~]# head-c Test Askdasjkdhsakhkjasd[[email protected]~]#


tip: When displaying characters , No line break by default


This article is from "Linux rookie" blog, please be sure to keep this source http://geekb0y.blog.51cto.com/10743719/1883539

One day a linux base command view file at the beginning of the content 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.