I have a large text file with blocks of text between two tokens I want to extract and put into a new file. I want each block extracted to go on single line (each block has its own line).
I used this solution: Extract lines between 2 tokens in a text file using bash
sed -n '/<!-- this is token 1 -->/{:a;n;/<!-- this is token 2 -->/b;p;ba}' inputfile
and it worked almost perfectly. the problem I have is that the block extracted is two lines and I want to condense it to one line. How can I achieve this?
Example:
<token1>
text to
extract
<token2>
<token1>
text to
extract
<token2>
output should look like:
text to extract
text to extract