gpt4 book ai didi

linux - 什么选项将使 Grep 命令从下到上搜索?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:23:28 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com