Linux Head Command Detailed __linux

Source: Internet
Author: User
# Head --help
Usage: head [options] ... [File] ...
Displays the first 10 lines of each specified file to standard output.
if more than one file is specified, the filename is given as the file header before each segment of output.
If you do not specify a file, or if the file is "-", the data is read from standard input.

parameters that must be used for long options are also required for short options.
  -C,  --bytes=[-]k     Displays the first K-byte content of each file, and
                        if the "-" parameter is attached, displays all remaining content except the last K-byte data for each file-
  N,--lines=[-]k      Displays the contents of the first k lines of each file, and
                        if the "-" argument is attached, all remaining contents are displayed except for the last K line of each file-
  Q,--quiet,--silent does not display the file header-V with the given file name.
  --verbose         always displays header--help with the given file
      name            Display this Help information and exit
      --version         display version information and exit

K with multiplication:
b 1000, KB, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, for T, P, E, Z, Y are equally applicable.
Sample
Original file
# cat t.txt 
Apple
Banana
Cherry
durian
Fig
Grape
Haw JuJube Kumquat
Lemon
Mango
Orange
Peach
//Statistics First, 13 lines 13 words 94 bytes
# cat T.txt |WC
     13
//default display 10 line # head
t.txt 
Apple
Banana
Cherry
Durian
Fig
Grape
Haw
jujube
Kumquat
Lemon  
//Display only the first 7 bytes (including carriage return line)   
# head-c7 t.txt 
Apple
/ /Show only the first 2 lines
# head-n2 t.txt 
Apple
Banana    
//only displays content other than the last 87 bytes (that is, first 7 bytes)
# head-c-87 T.txt
Apple
//only displays content other than the last 10 lines (that is, top 3 lines)
# head-n-10 t.txt 
Apple
Banana
Cherry

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.