命令简介

tac 命令用于按相同程序逐行连贯和打印文件内容。

和 cat 命令一样,将每个文件连贯到规范输入,但程序相同,逐行打印,首先打印最初一行。这对于查看按工夫顺序排列的日志文件很有用(例如),其中文件的最初一行蕴含最新的信息。

语法格局

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

选项阐明

-b          #在之前而不是之后连贯分隔符-r          #将分隔符作为根底正则表达式(BRE)解决-s          #应用STRING作为分隔符代替默认的换行符--help      #显示帮忙信息并退出--version   #显示版本信息并退出

利用举例

反向输入一个文件,从最初一行开始到第一行(与cat比照显示)

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

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

每天学一个 Linux 命令(99):nohup

每天学一个 Linux 命令(100):iotop