69、linux shell常用函数,tail

1、tail - output the last part of files

tail [OPTION][+/-num]... [FILE]...

2、option

-f,:output appended data as the file grows;

-s, :with -f, sleep for S seconds (default 1.0) between iterations.

-n, :output the last N lines, instead of the last 10

-c :output the last N bytes

第二条常用于跟踪日志,显示日志的新增信息

说明:

+ num 从第 num行以后开始显示。

- num 从距文件尾 num行处开始显示。

3、示例

tail -n 3 file //等价于tail -3 file

tail -n +3 file //从第3行以后显示,tail +3 file

tail -f file

tail -f -s 2 file

参考

1http://linux.die.net/man/1/tail

2https://wangyan.org/blog/linux-head-tail.html

3http://blog.csdn.net/carzyer/article/details/4759593

原文地址:https://www.cnblogs.com/mydomain/p/2229749.html