tail命令
来源:原创 更新时间:2018-08-26 00:13:43 作者:管理员 浏览:2121
- 命令描述
tail -f filename 会把 filename 文件里的最尾部的内容显示在屏幕上,并且不断刷新,只要 filename 更新就可以看到最新的文件内容。
- 命令语法
- 命令选项
-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."