Common Linux commands (14) and common linux commands
The tail 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 continuously, so that you can see the latest file content.
1.Command Format;
Tail [required parameters] [select parameters] [files]
2.Command function:
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.Instance used:
Instance 1:Display the last five lines of the file
Command: tail-n 5 log2014.log
Example 2:Displays files starting from line 1
Command: tail-n + 5 log2014.log
Example 3:View File Content cyclically
Command: tail-f test. log
Note: ping 192.168.120.204> test. log &
Ping the remote host in the background. And output the file to test. log;
[root@localhost ~]# ping 192.168.120.204 > test.log &[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 ms64 bytes from 192.168.120.204: icmp_seq=2 ttl=64 time=0.036 ms64 bytes from 192.168.120.204: icmp_seq=3 ttl=64 time=0.033 ms64 bytes from 192.168.120.204: icmp_seq=4 ttl=64 time=0.027 ms64 bytes from 192.168.120.204: icmp_seq=5 ttl=64 time=0.032 ms64 bytes from 192.168.120.204: icmp_seq=6 ttl=64 time=0.026 ms64 bytes from 192.168.120.204: icmp_seq=7 ttl=64 time=0.030 ms64 bytes from 192.168.120.204: icmp_seq=8 ttl=64 time=0.029 ms64 bytes from 192.168.120.204: icmp_seq=9 ttl=64 time=0.044 ms64 bytes from 192.168.120.204: icmp_seq=10 ttl=64 time=0.033 ms64 bytes from 192.168.120.204: icmp_seq=11 ttl=64 time=0.027 ms