每天进步一点点——linux——tail

一            简介

tail命令是从文件末尾输出文件,这个命令常用于看日志。

二            命令格式

tail[必要参数][选择参数][文件]  

三            常用参数

  -f,--follow[={name|descriptor}]

                即时输出文件变化后追加的数据。

  -n  <行数>          显示指定行数

 

四            所有参数

-c, --bytes=K        显示指定的字节数

  -f,--follow[={name|descriptor}]

                即时输出文件变化后追加的数据。

                        -f, --follow 等于--follow=descriptor

 -F            即--follow=name--retry

  -n,--lines=K           显示指定的行数

     --max-unchanged-stats=N

                           with --follow=name,reopen a FILE which has not

                           changed size after N(default 5) iterations

                           to see if it hasbeen unlinked or renamed

                           (this is the usualcase of rotated log files).

                           With inotify, thisoption is rarely useful.

     --pid=PID         同 -f 一起使用,当 PID 所对应的进程死去后终止

  -q,--quiet, --silent 不输出给出文件名的头

     --retry           即使目标文件不可访问依然试图打开;在与参数

                        --follow=name 同时使用时常常有用。

  -s,--sleep-interval=N   with -f, sleep forapproximately N seconds

                             (default 1.0)between iterations.

                           With inotify and--pid=P, check process P at

                           least once every Nseconds.

  -v,--verbose            always outputheaders giving file names

     --help            显示此帮助信息并退出

     --version         显示版本信息并退出

五            示例

5.1  显示文件后3行

[root@Nagios~]# tail -n 3 install.log

安装 words-3.0-17.el6.noarch

安装 redhat-indexhtml-6-1.el6.noarch

*** FINISHED INSTALLING PACKAGES***[root@Nagios ~]#

5.2  显示文件最后100个字节

[root@Nagios~]# tail -c 100 install.log

 words-3.0-17.el6.noarch

安装 redhat-indexhtml-6-1.el6.noarch

*** FINISHED INSTALLING PACKAGES***[root@Nagios ~]# 

5.1  动态显示文件

[root@Nagios~]# ping 11.10.111.254 >aaa.log &

[1] 10653

[root@Nagios~]# tail -f aaa.

aaa.log aaa.txt 

[root@Nagios~]# tail -f aaa.log

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

64 bytes from 11.10.111.254: icmp_seq=1ttl=255 time=1.27 ms

64 bytes from 11.10.111.254: icmp_seq=2ttl=255 time=1.29 ms

64 bytes from 11.10.111.254: icmp_seq=3ttl=255 time=1.99 ms

64 bytes from 11.10.111.254: icmp_seq=4 ttl=255time=1.67 ms

64 bytes from 11.10.111.254: icmp_seq=5ttl=255 time=1.94 ms

64 bytes from 11.10.111.254: icmp_seq=6ttl=255 time=1.67 ms

64 bytes from 11.10.111.254: icmp_seq=7ttl=255 time=2.58 ms

64 bytes from 11.10.111.254: icmp_seq=8ttl=255 time=1.14 ms

64 bytes from 11.10.111.254: icmp_seq=9ttl=255 time=1.35 ms

64 bytes from 11.10.111.254: icmp_seq=10ttl=255 time=1.65 ms

64 bytes from 11.10.111.254: icmp_seq=11ttl=255 time=2.00 ms

64 bytes from 11.10.111.254: icmp_seq=12ttl=255 time=2.36 ms

注意,此实验操作完成后记得要输入kill  10653(看上面ping命令后面的那个数字)

 

二            参考资料

http://vbird.dic.ksu.edu.tw/

http://gnu.org/licenses/gpl.html

man手册

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值