Grep 的 --max-count 选项从文件顶部开始搜索,并在该短语出现 max-count 次时停止。现在,我需要找出一个短语的最后 n 次出现?
我该怎么做?
最佳答案
使用 tac
来反转行的顺序(或者 tail -r
如果你的 tail
支持这个):
tac your_input_file | grep --max-count=N search-phrase
关于linux - 什么选项将使 Grep 命令从下到上搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17362271/