Tail command), tail command

Source: Internet
Author: User

Tail command

Original article: http://www.cnblogs.com/peida/archive/2012/11/07/2758084.html

The ail command writes the file to the standard output from the specified point. you can use the-f option of the tail command to conveniently check the changing log file. The tail content of the filename is displayed on the screen and refreshed, so that you can see the latest file content.

1. Command format;

Tail [required parameters] [select parameters] [files]

2. command functions:

Displays the content at the end of a specified file. If no file is specified, it is processed as an input. Common view log files.

3. command parameters:

-F: Read cyclically

-Q: no processing information is displayed.

-V: displays detailed processing information.

-C <number> Number of bytes displayed

-N <number of rows> Number of displayed rows

-- Pid = PID and-f are used together to indicate that the process ID ends after the PID dies.

-Q, -- quiet, -- silent never outputs the header of the given file name

-S, -- sleep-interval = S and-f are used together, indicating that the sleep seconds at each repeated interval

4. Example:

Instance 1: displays the content at the end of a file.

Command:

Tail-n 5 log2014.log

Output:

[Root @ localhost test] # tail-n 5 log2014.log

2014-09

2014-10

2014-11

2014-12

============================ [Root @ localhost test] #

Note:

Display the last five lines of the file

 

Instance 2: view the file content cyclically

Command:

Tail-f test. log

Output:

[Root @ localhost ~] # Ping 192.168.120.204> test. log &

[1] 11891 [root @ localhost ~] # Tail-f test. log

PING 192.168.120.204 (192.168.120.204) 56 (84) bytes of data.

64 bytes from 192.168.120.204: icmp_seq = 1 ttl = 64 time = 0.038 MS

64 bytes from 192.168.120.204: icmp_seq = 2 ttl = 64 time = 0.036 MS

64 bytes from 192.168.120.204: icmp_seq = 3 ttl = 64 time = 0.033 MS

64 bytes from 192.168.120.204: icmp_seq = 4 ttl = 64 time = 0.027 MS

64 bytes from 192.168.120.204: icmp_seq = 5 ttl = 64 time = 0.032 MS

64 bytes from 192.168.120.204: icmp_seq = 6 ttl = 64 time = 0.026 MS

64 bytes from 192.168.120.204: icmp_seq = 7 ttl = 64 time = 0.030 MS

64 bytes from 192.168.120.204: icmp_seq = 8 ttl = 64 time = 0.029 MS

64 bytes from 192.168.120.204: icmp_seq = 9 ttl = 64 time = 0.044 MS

64 bytes from 192.168.120.204: icmp_seq = 10 ttl = 64 time = 0.033 MS

64 bytes from 192.168.120.204: icmp_seq = 11 ttl = 64 time = 0.027 MS

 

[Root @ localhost ~] #

Note:

Ping 192.168.120.204> test. log & // ping the remote host in the background. And output the file to test. log. This method is also used for more than one file monitoring. Use Ctrl + c to terminate.

 

Instance 3: displays files from row 3

Command:

Tail-n + 5 log2014.log

Output:

[Root @ localhost test] # cat log2014.log

2014-01

2014-02

2014-03

2014-04

2014-05

2014-06

2014-07

2014-08

2014-09

2014-10

2014-11

2014-12

====================================

[Root @ localhost test] # tail-n + 5 log2014.log

2014-05

2014-06

2014-07

2014-08

2014-09

2014-10

2014-11

2014-12

====================================

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.