我有一个 html 文件,我想用 sed 实用程序编辑从第 8 行到最后一行,即不更改 1-7 和最后一行。
例子:
line 1 <i>some text<i>
line 2 <i>some text<i>
line 3 <i>some text<i>
line 4 <i>some text<i>
line 5 <i>some text<i>
line 6 <i>some text<i>
line 7 <i>some text<i>
line 8 <i>some text<i>
line 9 <i>some text<i>
line 10 <i>some text<i>
S <i>some text<i>
o <i>some text<i>
- <i>some text<i>
o <i>some text<i>
n <i>some text<i>
line N <i>some text<i>
到
line 1 <i>some text<i>
line 2 <i>some text<i>
line 3 <i>some text<i>
line 4 <i>some text<i>
line 5 <i>some text<i>
line 6 <i>some text<i>
line 7 <i>some text<i>
line 8 some text
line 9 some text
line 10 some text
S some text
o some text
- some text
o some text
n some text
line N <i>some text<i>
我该怎么做?提前感谢您的建议和帮助。问候
答案1
如果您的限制达到并包括倒数第二行,那么您可以使用它$!
作为替换的条件:
sed '8,$ { $! s:</\?i>::g }' infile