【发布时间】:2021-03-05 19:58:49
【问题描述】:
我需要删除匹配的一行和它之前的一行。 例如,在下面的文件中,我需要删除第 1 行和第 2 行。
我试过 "grep -v -B 1 "page.of." 1.txt 我希望它不会打印匹配的行和上下文。
我尝试了How do I delete a matching line, the line above and the one below it, using sed?,但无法理解 sed 的用法。
---1.txt--
**document 1** -> 1
**page 1 of 2** -> 2
testoing
testing
super crap blah
**document 1**
**page 2 of 2**
【问题讨论】:
标签: unix sed grep pattern-matching