我不知道這樣做的好方法(請參閱/ awk/perl);我結合的HTML文件的多個章節,它具有以下結構保存緩衝區以重新排列文本
<a href="#chapter11">title</a>
<a href="#chapter12">title</a>
<a href="#chapter13">title</a>
<p>first chapter contents, multiple
pages</p>
<a href="#chapter21">title</a>
<a href="#chapter22">title</a>
<a href="#chapter23">title</a>
<p>Second chapter contents, multiple pages
more informations</p>
<a href="#chapter31">title</a>
<a href="#chapter32">title</a>
<a href="#chapter33">title</a>
<p>Third chapter contents, multiple pages
few more details</p>
我希望他們能夠重新組織像下面
<a href="#chapter11">title</a>
<a href="#chapter12">title</a>
<a href="#chapter13">title</a>
<a href="#chapter21">title</a>
<a href="#chapter22">title</a>
<a href="#chapter23">title</a>
<a href="#chapter31">title</a>
<a href="#chapter32">title</a>
<a href="#chapter33">title</a>
<p>first chapter contents, multiple
pages</p>
<p>Second chapter contents, multiple pages
more informations</p>
<p>Third chapter contents, multiple pages
few more details</p>
我有一個HTML五章重新進行排列。我試圖採用sed保持緩衝區,但這似乎是困難的,我的知識。我不限於sed或awk。任何幫助將不勝感激,謝謝。
編輯
對不起改變的源文件,它也有幾行不總是啓動要麼
<a or <p
反正是有有像sed逆選擇劇本,像
/^<a!/p/
通過包括(bz的mac BSD sed)很好地工作;在關閉像(sed -n'/^ kuruvi
編輯我的答案。 'sed -i'也應該工作,但需要對代碼進行一些重構。 – pfnuesel
感謝pfnuessel,我的源文件中也有幾行並不總是以 kuruvi