【Linux】tail命令
用途
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]
#---------------------------------------------------------
……
声明:书写博客不易,转载请注明出处,请支持原创,侵权将追究法律责任
个性签名:人的一切的痛苦,本质上都是对自己无能的愤怒
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!