I want to do substitution using sed command, but also this should not get applied to specific range of lines matching some pattern/word.
File has below lines:
startline1
top
nice
good
bad
nice
nice
verybad
Extremely bad
bad
nice
endline1
nice
Trail from my end:
sed -i '/startline1/,/endline1/ s/nice/decent/'
The substitute must happen between startline1 and endline1
But must exclude the update between bad and verybad words
With the above command I get result as below:
startline1
top
decent
good
bad
decent
decent
verybad
Extremely bad
bad
decent
endline1
nice
- This will do a replacement between only
startline1andendline1, which is as expected. - But now I don't want the update to happen between
badandverybad.
Expected Result:
startline1
top
decent
good
bad
nice
nice
verybad
Extremely bad
bad
decent
endline1
nice
Any suggestion on this would be of help.