您可以在终端中使用tac命令吗?
我正在尝试从命令行(使用终端)以相反的顺序搜索大文件。我找到了tac命令: http://clifgriffin.com/2008/ 11/25 / tac-and-reverse-grep /
I'm trying to search a large file in reverse order from the command line (using terminal). I found the tac command: http://clifgriffin.com/2008/11/25/tac-and-reverse-grep/
tac是cat的倒数。但是,当我尝试在终端中使用tac命令时,它说该命令不存在。有什么方法可以在终端中使用tac?还有哪些其他快速方法可以通过命令行从头开始搜索文件?
tac is the inverse of cat. However, when I try to use the tac command in terminal, it says that command doesn't exist. Is there a way I'd be able to use tac in terminal? What are some other fast ways to search a file from the end via the command line?
MacOS版本的 tail
支持 -r
(反向)选项,默认
从头开始显示整个文件。因此, tail -r文件名
应该与
完全等效于 tac文件名
。
The MacOs version of tail
support the -r
("reverse") option, and defaults
to displaying the entire file from the end. So tail -r filename
should be
exactly equivalent to tac filename
.
或者,您可以尝试从源代码自己构建tac。它是GNU coreutils 程序包的一部分。
Or, you could try building tac yourself from the source code. It's part of the GNU coreutils package.