awk RS 正則例子

說明藍色=命令名稱html

    淺綠=命令參數ide

    淺藍=選項學習

    紫色=目錄spa

    系統環境:Arch Linux x86_64orm

    awk版本: GNU Awk 4.1.0htm


沒有系統的學習過awk相關應用,一直覺得RS不支持正則,今天無聊嘗試了一下,原來RS正則用起來也挺犀利的。blog

內容以下:get

<pre id="help-1"><b>-l</b>     use a long listing format</pre>
</td>
</tr><tr>
<td>
<pre id="help-2"><b>-a</b>, <b>--all</b>
do not ignore entries starting with .</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div style="height: 5px;"></div>
<div style="height: 100px;"></div>
<div>
<table id="help" width="100%">
<tbody>
<tr>
<td>
<pre id="help-0">list directory contents</pre>
</td>
</tr><tr>
<td>

想獲得以下內容:it

<b>-l</b>     use a long listing format
<b>-a</b>, <b>--all</b>
do not ignore entries starting with .
list directory contents


awk語句:awk  'BEGIN{RS="</?pre[^>]*>"}!(NR%2)filetable

效果如圖:225234899.png

相關文章
相關標籤/搜索