14.每日一个Linux命令----tail

描述:用于显示指定文件末尾内容,不指定文件时,做为输入信息进行处理。经常使用查看日志文件。日志

用法:tail [option] filecode

经常使用参数:进程

-f 循环读取io

-c<数目> 显示的字节数test

-n<行数> 显示行数file

--pid=PID 与-f合用,表示在进程ID,PID死掉以后结束. 循环

-s, --sleep-interval=S 与-f合用,表示在每次反复的间隔休眠S秒 im

示例:1显示文件末尾内容文件

[root@localhost test]# tail -n 5 log2014.log 
2014-09
2014-10
2014-11
2014-12

2.循环查看文件内容ping

[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

3.从第5行开始查看

[root@localhost test]# tail -n +5 log2014.log
2014-05
2014-06
2014-07
2014-08
2014-09
2014-10
2014-11
2014-12
相关文章
相关标签/搜索