How to remove a tagged block of text in a file?

Posted by EmpireJones on Server Fault See other posts from Server Fault or by EmpireJones
Published on 2010-05-02T08:11:55Z Indexed on 2010/05/02 8:19 UTC
Read the original article Hit count: 221

Filed under:
|
|
|
|

How can I remove all instances of tagged blocks of text in a file with sed, grep, or another program?

If I have a file which contains:

random
text
// START TEXT
internal
text
// END TEXT
more
random
// START TEXT
asdf
// END TEXT
text

how can I remove all blocks of text within the start/end lines, produce the following?

random
text
more
random
text

© Server Fault or respective owner

Related posts about sed

Related posts about grep