天天学一个 Linux 命令(102):tac

命令简介

tac 命令用于按相反顺序逐行链接和打印文件内容。正则表达式

和 cat 命令同样,将每一个文件链接到标准输出,但顺序相反,逐行打印,首先打印最后一行。这对于检查按时间顺序排列的日志文件颇有用(例如),其中文件的最后一行包含最新的信息。centos

语法格式

tac [OPTION] ... [FILE] ...

选项说明

-b          #在以前而不是以后链接分隔符
-r          #将分隔符做为基础正则表达式(BRE)处理
-s          #使用STRING做为分隔符代替默认的换行符
--help      #显示帮助信息并退出
--version   #显示版本信息并退出

应用举例

反向输出一个文件,从最后一行开始到第一行(与cat对比显示)centos7

[root@centos7 ~]# tac test.txt 
This is also also a test line
This is also a test line
This is also a test line
This is a test line
This is a test line
This is a test line
[root@centos7 ~]# cat test.txt 
This is a test line
This is a test line
This is a test line
This is also a test line
This is also a test line
This is also also a test line

天天学一个 Linux 命令(98):crontab日志

天天学一个 Linux 命令(99):nohupcode

天天学一个 Linux 命令(100):iotopcrontab

相关文章
相关标签/搜索