在某个模式之后擦除文件中的所有行,不包括包含该模式的行
Erase all lines in a file AFTER some pattern, EXCLUDING the line containing the pattern
我一直在到处寻找,但找不到任何解决方案来让 sed
擦除所有行
在某个模式之后的文件中,排除带有该模式的行。
我希望该单行的简单变体 sed '/pattern/,$d'
可以工作,但无济于事。
有人吗?
让我们将@Aaron 的评论提升为它应得的答案:
You can use sed '/pattern/q'
; it'll just stop processing after
having printed the line matching the pattern, effectively omitting all
the following lines in the output stream
如此简单却又如此难找。
我一直在到处寻找,但找不到任何解决方案来让 sed
擦除所有行
在某个模式之后的文件中,排除带有该模式的行。
我希望该单行的简单变体 sed '/pattern/,$d'
可以工作,但无济于事。
有人吗?
让我们将@Aaron 的评论提升为它应得的答案:
You can use
sed '/pattern/q'
; it'll just stop processing after having printed the line matching the pattern, effectively omitting all the following lines in the output stream
如此简单却又如此难找。