gpt4 book ai didi

sed 找到带有固定冠词 (a, an, the) 的行

转载 作者:行者123 更新时间:2023-12-05 01:19:28 24 4
gpt4 key购买 nike

我应该找到我自己设置的文章行。在前 10 行中搜索。

sed -n '/the/p' file.txt | sed -n '/ a /p' file.txt 

将只显示最后一条命令的输出。还有

sed -n '1,10 /the/p' file

sed -n 1,10p '/the/p' file

不工作,我发现 range 只在像这样的模式中使用

[range]/s/pattern/pattern/p

如何组合多个条件和行范围?

文件示例:

For the first time since early February
the top three films at the weekend
box office were all new releases
and leading the way was
Fox's Bohemian Rhapsody
with a $50 million
chart-topping performance
well above expectations.
That said, the weekend isn't all about
new releases as the holdovers

输出应该是:

 For the first time since early February
the top three films at the weekend
and leading the way was
with a $50 million
That said, the weekend isn't all about
new releases as the holdovers

最佳答案

  • 获取包含

    的行
    sed -n '1,10{/\<the\>/p}' file
  • 获取包含theaan

    的行
    sed -n '1,10{/\<\(the\|a\|an\)\>/p}' file

关于sed 找到带有固定冠词 (a, an, the) 的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53144965/

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