2

I have a html file and i want to edit from 8th line till next to the last line i.e no changes to 1-7 and the last line with sed utility.

Example:

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>    

To

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>

How can i? Thanks in advance for suggestions and help . Regards

2

If your limit is up to and including next-to-last line, you can get away with using $! as a condition for the substitution:

sed '8,$ { $! s:</\?i>::g }' infile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.