Removing lines between tags in a text file
<p>I have many text files containing annotations. The original text is marked with lines containing the words:</p>

<pre><code>START OF TEXT OF PASSAGE 1

END OF TEXT OF PASSAGE 1
</code></pre>

<p>Obviously I can search each document for the phrase <code>START OF TEXT</code> and delete everything up to it. Then search for <code>END OF TEXT</code> and start selecting text for deletion until I get to the next <code>START OF TEXT</code>.</p>

<p>I have come up with this design so far:</p>

<pre><code>#!/bin/bash

a="START OF PROJECT"
b="END OF PROJECT"

while read line; do
    if line contains a; do
         while read line; do
            'if line does not contain b'
               'append the line to output.txt'; fi
         done
     done
     fi
done
</code></pre>

<p>Perhaps there is an easier way using sed, awk, grep and pipes?</p>

<pre><code>'for every document' 'loop through it doing this' ('find the original text between START and END' | &gt;&gt; output.txt)
</code></pre>

<p>Unfortunately I am poor at bash and ignorant of sed/awk.</p>

<p>The reason for this is that I am assembling a huge text document that is a concatenation of thousands of marked up documents &ndash; each of which contains some annotated passages.</p>