欢迎访问linux宝典,请记住本站唯一域名:www.linuxbaodian.com

tail命令

来源:原创    更新时间:2018-08-26 00:13:43    作者:管理员    浏览:2121
  • 命令描述
ail 命令可用于查看文件的内容,有一个常用的参数 -f 常用于查阅正在改变的日志文件。

tail -f filename 会把 filename 文件里的最尾部的内容显示在屏幕上,并且不断刷新,只要 filename 更新就可以看到最新的文件内容。
  • 命令语法
tail [选项] [参数]
  • 命令选项
-f 循环读取
-q 不显示处理信息
-v 显示详细的处理信息
-c<数目> 显示的字节数
-n<行数> 显示行数
--pid=PID 与-f合用,表示在进程ID,PID死掉之后结束.
-q, --quiet, --silent 从不输出给出文件名的首部
-s, --sleep-interval=S 与-f合用,表示在每次反复的间隔休眠S秒
  • 命令参数
文件名
  • 命令实例

实例1:从尾部查看文件

[root@linuxbaodian baodian]# tail -1 baodian
we are studying...
[root@linuxbaodian baodian]# tail -2 baodian
this is study linux site
we are studying...
[root@linuxbaodian baodian]# tail -3 baodian
this is linuxbaodian.com
this is study linux site
we are studying...

实例2:显示文件最后的XX个字符

[root@linuxbaodian baodian]# tail -c 11 baodian
tudying...
[root@linuxbaodian baodian]# tail -c 18 baodian
e are studying...
[root@linuxbaodian baodian]# tail -c 19 baodian
we are studying...

实例3:实时显示文件更新

[root@linuxbaodian files]# tail -F 01.txt What? Mom asked.Let's run through the rain! She repeated.No, honey. We'll wait until it slows down a bit. Mom replied.Don't you remember? When you were talking to Daddy about his cancer, you said, If God can get us through this, he can get us through anything!
This young child waited about another minute and repeated: "Mom, let's run through the rain."
We'll get soaked if we do. Mom said.
No, we won't, Mom. That's not what you said this morning, the young girl said as she tugged at her Mom's arm."

上一条命令:wc

下一条命令:head

笔记分享

表情

共0条分享记录
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~

相关内容

最受欢迎

猜你喜欢

最受争议