Tail
Name: tail-output the last part of the files output file
Function Description: The tail command writes the file to the standard output from a specified point. You can use the-f option to conveniently view the log file being changed, the tail-f filename will output the content at the end of the filename and refresh it continuously. You can see the continuously updated content.
Parameters:
-F: Read follow cyclically
-V: displays detailed processing information.
-N: number of lines displayed
-P -- pid and-f are used together to indicate that when the file specified by-f dies, the process ends. It is identified by pid.
-S-sleep-interval = S is used with-f, indicating that the sleep seconds at each repeated interval.
-Q-quiet never outputs the header to the file.
Instance:
1) display the content at the end of the file
[Root @ bogon ~] # Tail-n 10/var/log/messages
Apr 25 22:25:16 bogon last message repeated 14 times
Apr 25 22:26:21 bogon last message repeated 29 times
Apr 25 22:30:59 bogon last message repeated 2 times
Apr 25 22:31:20 bogon last message repeated 12 times
Apr 25 22:31:22 bogon dhclient: DHCPREQUEST on eth0to
2) view the file content cyclically and update it continuously. When the pid is dead, the view ends.
[Root @ bogon ~] # Ping 192.168.40.1> test. log &
[1] 4911
[Root @ bogon ~] # Tail-n 3-f test. log
64 bytes from 192.168.40.1: icmp_seq = 11 ttl = 255 time = 0.859 MS
64 bytes from 192.168.40.1: icmp_seq = 12 ttl = 255 time = 0.767 MS
64 bytes from 192.168.40.1: icmp_seq = 13 ttl = 255 time = 0.564 MS
64 bytes from 192.168.40.1: icmp_seq = 14 ttl = 255 time = 0.748 MS
64 bytes from 192.168.40.1: icmp_seq = 15 ttl = 255 time = 0.724 MS
[Root @ bogon ~] # Jobs
[1] + Running ping192.168.40.1> test. log &
[Root @ bogon ~] # Fg 1
Ping 192.168.40.1> test. log
Note: ping 192.168.40.1> test. log is placed in the background for execution. After checking, run the jobs command to view the background job fg 1 and call it back to the front-end. Then press ctrl + c to complete the process.
Another thing is: ping 192.168.40.1> test. log, so the test. log content should not have only one, because the previous one will be overwritten later. But after I finish all the operations, how much content does cat view test. log?
3) exclude the first five rows of content from the list and display them from the first row.
[Root @ bogon ~] # Tail-n + 5 2.log
5
6
7
8
9
----------------------- Subsequent self-Summary --------------------
Tail is mainly used to view our files, starting from the end of the article. One of the main functions is-f follow continuous viewing.
File updates. It is mainly reflected in the ability to view the content. Of course, all the content that can be viewed can be processed: for example, selecting, awk capturing and displaying, and directing to another file. This is flexible. This should be combined with our processing commands.