Grep 从文件末尾开始

Grep from end of file

有没有办法从文件末尾而不是开头开始 grep 搜索?这是从头开始的 --

$ grep -irn 'Qyt13_pUFjQ' ./

我正在寻找的信息接近文件末尾,但需要几分钟才能从头到尾。

您可以tail -n xxxx file.txt | grep ...通过 grep 管道传输文件的最后 xxxx 行。

您可以使用 tac 从末尾到开头逐行读取文件,然后如果需要可以用另一个 tac 再次切换它。