Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
    
    
Not really helpful, See there are two range as i don't know the number of last line. (8,$|$!) but i don't think it will work. Any workaround will be highly appreciated. –  22lk94k943 only May 3 '13 at 12:59

1 Answer 1

up vote 2 down vote accepted

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
share|improve this answer
    
Worked like a charm, Thanks bro –  22lk94k943 only May 3 '13 at 13:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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