我想從文件中提取<div class="AA">
和<div class="clear"></div>
之間的行。awk顯示兩個匹配之間的行
正則表達式與sed
和grep
也是受歡迎的。
更新
這裏是我的巨大的XML文件的一部分:
RUBBISH
RUBBISH
.
.
.
<div class="span9">
<div class="results-count">AAA</div>
<div class="AA">
<div class="A"><a href="/TEST">BBB</a>
</div>
<div class="BB"><span>CCC</span><br/><a href="/TEST1" class="B">DDD</a>
<div></div><span>EEE</span><br/><img src="TEST2" title="C"/><a href="/TEST3" class="D">FFF</a>,
<a href="/TEST4" class="E">GGG</a>
<div class="clear"></div><a href="/TEST5" class="details">Details</a>
</div>
<pre>HHH</pre>
<div class="clear"></div>
.
.
.
<div class="span9">
<div class="results-count">AAA</div>
<div class="AA">
<div class="A"><a href="/TEST">BBB</a>
</div>
<div class="BB"><span>CCC</span><br/><a href="/TEST1" class="B">DDD</a>
<div></div><span>EEE</span><br/><img src="TEST2" title="C"/><a href="/TEST3" class="D">FFF</a>,
<a href="/TEST4" class="E">GGG</a>
<div class="clear"></div><a href="/TEST5" class="details">Details</a>
</div>
<pre>HHH</pre>
<div class="clear"></div>
RUBBISH
RUBBISH
<div class="span9">
<div class="results-count">AAA</div>
<div class="AA">
<div class="A"><a href="/TEST">BBB</a>
</div>
<div class="BB"><span>CCC</span><br/><a href="/TEST1" class="B">DDD</a>
<div></div><span>EEE</span><br/><img src="TEST2" title="C"/><a href="/TEST3" class="D">FFF</a>,
<a href="/TEST4" class="E">GGG</a>
<div class="clear"></div><a href="/TEST5" class="details">Details</a>
</div>
<pre>HHH</pre>
<div class="clear"></div>
.
.
.
您還可以檢查內容:HTTP: //stackoverflow.com/questions/12918292/g rep-access-multiple-lines-find-all-words-between-patterns – qqibrow 2015-01-21 05:32:02
@Mortez提供了一個示例文件。 – 2015-01-21 05:34:59