码迷,mamicode.com
首页 > 系统相关 > 详细

【Linux】tail命令

时间:2018-08-15 16:53:18      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:variable   use   cache   for   global   man   element   roo   ctrl   

用途

tail命令主要用于取出后边几行


全称

tail命令的全称即为tail(尾巴)


参数

-n :后边接数字,代表显示几行的意思

-f :循环读取

-q :不显示处理信息

-v :显示详细的处理信息


案例

案例一:显示文件最后5行内容

[root@bigdata ~]# tail -5 /etc/man_db.conf
#
#---------------------------------------------------------
# Flags.
# NOCACHE keeps man from creating cat pages.
#NOCACHE


案例二:循环查看文件内容

[root@bigdata /]# ping localhost >test.txt &

[4] 9944
[root@bigdata /]# tail -f test.txt
64 bytes from localhost (127.0.0.1): icmp_seq=1791 ttl=64 time=0.112 ms
64 bytes from localhost (127.0.0.1): icmp_seq=1792 ttl=64 time=0.161 ms
  bytes from localhost (127.0.0.1): icmp_seq=1793 ttl=64 time=0.166 ms
64 bytes from localhost (127.0.0.1): icmp_seq=1794 ttl=64 time=0.133 ms

….


想要结束按CTRL+C即可


案例三:从第5行开始显示文件

[root@bigdata /]# tail -n +5 /etc/man_db.conf
# their PATH environment variable. For details see the manpath(5) man page.
#
# Lines beginning with `#‘ are comments and are ignored. Any combination of
# tabs or spaces may be used as `whitespace‘ separators.
#
# There are three mappings allowed in this file:
# --------------------------------------------------------
# MANDATORY_MANPATH            manpath_element
# MANPATH_MAP        path_element    manpath_element
# MANDB_MAP        global_manpath    [relative_catpath]
#---------------------------------------------------------

……

【Linux】tail命令

标签:variable   use   cache   for   global   man   element   roo   ctrl   

原文地址:https://www.cnblogs.com/OliverQin/p/9482051.html

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