用途
tail命令主要用于取出后边几行
全称
tail命令的全称即为tail(尾巴)
参数
-n :后边接数字,代表显示几行的意思
-f :循环读取
-q :不显示处理信息
-v :显示详细的处理信息
案例
案例一:显示文件最后5行内容
[[email protected] ~]# tail -5 /etc/man_db.conf
#
#---------------------------------------------------------
# Flags.
# NOCACHE keeps man from creating cat pages.
#NOCACHE
案例二:循环查看文件内容
[[email protected] /]# ping localhost >test.txt &
[4] 9944
[[email protected] /]# 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行开始显示文件
[[email protected] /]# 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]
#---------------------------------------------------------
……
原文地址:https://www.cnblogs.com/OliverQin/p/9482051.html