【发布时间】:2019-06-28 11:18:02
【问题描述】:
我有一个类似的文本文件
some
important
content
goes here
---from here--
some
unwanted content
我正在尝试删除---from here-- 之后的所有行,包括---from here--。也就是说,期望的输出是
some
important
content
goes here
我尝试了sed '1,/---from here--/!d' input.txt,但它没有删除---from here-- 部分。如果我使用sed '/---from here--.*/d' input.txt,它只会删除---from here-- 文本。
如何删除包含该模式的模式后的线条?
编辑
我可以通过执行第一个操作并将其输出传递到第二个操作来实现它,例如sed '1,/---from here--/!d' input.txt | sed '/---from here--.*/d' > outputput.txt。
有单步解决方案吗?
【问题讨论】: