Http://www.cnblogs.com/peida/archive/2012/11/07/2758084.html
The tail command writes the file to standard output starting at the specified point. Using the-f option of the tail command makes it easy to see the log files that are being changed, TAIL-F filename will display the most trailer in filename on the screen, and not only refresh, Enables you to see the latest file content.
1. command format ;
tail[necessary parameters [selection parameters] [file]
2. Command function:
Used to display the content at the end of the specified file, and is processed as input when the file is not specified. Common view log Files .
3. Command parameters:
-F Loop Read
-Q does not display processing information
-V displays detailed processing information
Number of-c< > bytes displayed
-n< lines > Display rows
--pid=pid is shared with-F, which means that the process ends after the id,pid dies.
-Q,--quiet,--silent never output the header of the file name
-S,--sleep-interval=s is combined with-F, which means sleep s seconds at each repetition interval
4. usage Examples:
Example 1: Displaying the end of a file
Command:
Tail-n 5 Log2014.log
Output:
[[email protected] test] # tail-n 5 log2014.log
2014-09
2014-10
2014-11
2014-12
==============================[root@localhost test]#
Description
Displays the last 5 lines of the file
Example 2: Looping through the contents of a file
Command:
Tail-f Test.log
Output:
[[Email protected] ~] # Ping 192.168.120.204 > Test.log &
[1] 11891[root@localhost ~]# tail-f test.log
PING 192.168.120.204 (192.168.120.204)bytes of data.
Bytes from 192.168.120.204:icmp_seq=1 ttl=64 time=0.038 Ms
Bytes from 192.168.120.204:icmp_seq=2 ttl=64 time=0.036 Ms
Bytes from 192.168.120.204:icmp_seq=3 ttl=64 time=0.033 Ms
Bytes from 192.168.120.204:icmp_seq=4 ttl=64 time=0.027 Ms
Bytes from 192.168.120.204:icmp_seq=5 ttl=64 time=0.032 Ms
Bytes from 192.168.120.204:icmp_seq=6 ttl=64 time=0.026 Ms
Bytes from 192.168.120.204:icmp_seq=7 ttl=64 time=0.030 Ms
Bytes from 192.168.120.204:icmp_seq=8 ttl=64 time=0.029 Ms
Bytes from 192.168.120.204:icmp_seq=9 ttl=64 time=0.044 Ms
Bytes from 192.168.120.204:icmp_seq=10 ttl=64 time=0.033 Ms
Bytes from 192.168.120.204:icmp_seq=11 ttl=64 time=0.027 Ms
[Root@localhost ~]#
Description
Ping 192.168.120.204 > Test.log &//Ping remote host in background. and output files to Test.log; This practice also allows for more than one file to monitor. Use CTRL + C to terminate.
Example 3: Displaying a file starting from line 5th
Command:
Tail-n +5 Log2014.log
Output:
[[email protected] 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
==============================
One Linux command per day: Tail command