码迷,mamicode.com
首页 > 其他好文 > 详细

17-tail 简明笔记

时间:2016-12-17 01:27:11      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:.com   comm   字符   路径   标准输入   bsp   指定   默认   mon   

显示文件的最后一部分(尾部)

tail [options] [file-list]

 

参数

file-listtail要显示的文件的路径名列表。当制定多个文件时,tail在显示每个文件的内容之前先显示对应的文件名

如果不指定参数或使用连字符(-)来代替文件名,tail就从标准输入获得输入

 

选项

-c            输出最后几个字节

-f             在文件增长时,动态追加数据

-n            输出最后n行

-s n         与-f选项合用,使tail每隔n秒检查一次文件的输出,默认5秒

 

示例

原文件

技术分享
$ cat demo
line one
line two
line three
line four
line five
line six
line seven
line eight
line nine
line ten
line eleven
技术分享

 

tail

技术分享
$ tail demo
line two
line three
line four
line five
line six
line seven
line eight
line nine
line ten
line eleven
技术分享

显示默认的倒数10行

 

tail -n

$ tail -4 demo
line eight
line nine
line ten
line eleven

显示指定行数的尾部

 

tail -n +7

$ tail -n +7 demo
line seven
line eight
line nine
line ten
line eleven

显示指定从第7行起到文件尾部

 

tail -c

$ tail -c 7 demo
eleven

显示指定数量的末尾字符

17-tail 简明笔记

标签:.com   comm   字符   路径   标准输入   bsp   指定   默认   mon   

原文地址:http://www.cnblogs.com/luoahong/p/6188575.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!