我需要刪除一條匹配線和一條匹配線。 e.g在文件下我需要刪除線1 & 2.如何刪除匹配的行和上一行?
我試過的 「grep -v -B 1」 的頁面。 。「的1.txt ,我估計它不打印matchning線和背景。
我試過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**
嘗試['tac file | sed -e'/ foo /,+ 1d'| tac'](http://stackoverflow.com/a/31227307/2297751) – Jon