tac
rose1 发表于 2020-07-08 18:02浏览次数:
在类似Unix的操作系统上,tac命令可接反并逐行打印文件内容。
本文档介绍tac的GNU / Linux版本。
On Unix-like operating systems, the tac command catenates and prints the contents of files, in reverse, line by line.
This document covers the GNU/Linux version of tac.
目录:
1 tac 运行系统环境
2 tac 说明
3 tac 语法
4 tac 例子
tac 运行系统环境
tac 说明
tac(向后为“ cat”)将每个FILE连接到标准输出,就像cat命令一样,但是相反:逐行,首先打印最后一行。 例如,这对于检查按时间顺序排列的日志文件很有用,该文件的最后一行包含最新信息。
如果未指定FILE,或者FILE指定为“-”,则tac反转标准输入的内容。
tac (which is "cat" backwards) concatenates each FILE to standard output just like the cat command, but in reverse: line by line, printing the last line first. This is useful (for instance) for examining a chronological log file in which the last line of the file contains the most recent information.
If no FILE is specified, or if the FILE is specified as "-", tac reverses the contents of standard input.
tac 语法
tac [OPTION] ... [FILE] ...
Options
-b, --before
|
在输出的每一行之前而不是之后附加行分隔符。
|
-r, --regex
|
将行分隔符解释为正则表达式(与-s选项一起使用,请参见下文)。
|
-s, --seperator=STRING
|
使用STRING代替换行符作为行分隔符。
|
--help
|
显示命令帮助并退出。
|
--version
|
输出版本信息并退出。
|
tac [OPTION] ... [FILE] ...
Options
-b, --before
|
attach the line separator before each line of output instead of after.
|
-r, --regex
|
interpret the line separator as a regular expression (useful with the -s option, see below).
|
-s, --seperator=STRING
|
use STRING as the line separator instead of a newline.
|
--help
|
display command help and exit.
|
--version
|
output version information and exit.
|
tac 例子
tac file1.txt
从最后一行到最后一行反向打印file1.txt的行。
tac file1.txt
Prints the lines of file1.txt in reverse, from last line to first.