Linux head/tail Command Detailed

Source: Internet
Author: User
Tags inotify

The Head command is used to display the contents at the beginning of the file. By default, the head command displays the contents of the first 10 lines of the file.

The Tail command is used to display the content at the end of a file. By default, the Taild command displays the contents of the next 10 lines of the file.

Head Common Command parameters
  -C,--bytes=[-]k print the first         K bytes of each file;                             With the leading '-', print all and the last                             K bytes of each file  -N,--lines=[-]k print the first         K lines ins Tead of the first ten;                             With the leading '-', print all and the last                             K lines of each file-  q,--quiet,--silent    never print headers gi Ving Tsun file Names  -V,--verbose always            print headers giving file names      --help display this help and     exit      --version  output version information and exit
Tail scene commands
 -C,--bytes=k output the last K bytes; Alternatively, use-c +k to output bytes starting with the Kth of each file-f,--follow[={name                           |descriptor}] Output appended data as the file grows; -F,--follow, and--follow=descriptor are equivalent-f same as--follow=                           Name--retry-n,--lines=k output the last K-lines, instead of the last 10; or use-n +k to output lines starting with the Kth--max-unchanged-stats=n with--follow=na                           Me, reopen a FILE which have not changed size after N (default 5) iterations                           To see if it have been unlinked or renamed (this is the usual case of rotated log files).      With inotify, this option is rarely useful. --pid=pid With-f, terminate after Process ID, PID dies-q,--quiet,--silent never output headers giving file names--retry keep tryi ng to open a file even if it is or becomes inaccessible; Useful when following by name, i.e, with--follow=name-s,--sleep-interval=n with-f, SLE                           EP for approximately N seconds (default 1.0) between iterations.  With INotify and--pid=p, check the process P at least once every N seconds.   -V,--verbose always output headers giving file names--help display this Help and exit--version Output version information and exit
Common Command Display
Head: Displays the first few lines of the file, the default 10 lines  head-n 2/home/omc/h.txt==>head-n 3 = = Head-3    can be directly followed by the number of rows cat h.txt | grep-v "Hello"     filter Off specific strings, inefficient, because there is a pipeline ==>grep-v "Hello" h.txt  can be directly with the file name, efficient tail: Display the last few lines of the file, the default 10 lines Tail-10/home/omc/h.txt    Displays the last 10 lines tail-f/home/omc/h.txt     real-time trace file, if the file does not exist, then terminates tail-f/home/omc/h.txt     If the file does not exist, will continue to try Head-30/home/omc/ H.txt | Tail-11/home/omc/h.txt   output 20-30 lines of a file shows the first n rows of a file head-n 5 log2014.log output file except for the last n rows head-n-6 Log2014.log Show file from line 5th tail-n +5 log2014.log    "Show all contents of file" Tail-n 5  log2014.log    "show only last 5 rows"  root more/ Less similar

Linux head/tail Command Detailed

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.