2016-12-01 5 views
0

オンラインのCLINEを(status_icon_onlineで)抽出する方法は?私は実行して、すべてのCLINESを抽出することができます。sed/grepを使って、条件付きで2つの単語間のテキストを抽出するには?

cat test.txt | sed -n 's:.*">C\(.*\)</a>.*:\1:p' 

が、私はちょうどオンラインのものをしたい、結果は次のようにする必要があります:

C:free.cccamlux.co 21900 FREEAC5p08w cccamlux.com

私のtest.txtというファイル:

> <tr> 
<td valign="middle"> 
<a href="/info/CCcam/free.cccamlux.co_21900_FREEAC5p08w_cccamlux.com/75e56a5655a02b839664981da2f69445937f6bbf" title="View line details for free Cline C: free.cccamlux.co 21900 FREEAC5p08w cccamlux.com">C: free.cccamlux.co 21900 FREEAC5p08w cccamlux.com</a> 
</td> 
<td class="text-center"> 
<span class="span_tooltip glyphicon glyphicon-remove-sign status_icon_online" data-toggle="tooltip" rel="tooltip" data-placement="left" title="CCcam server down or invalid cline credentials"></span> 
</td> 
<td align="center" valign="middle"> 
<a href="/info/CCcam/free.cccamlux.co_21900_FREEAC5p08w_cccamlux.com/75e56a5655a02b839664981da2f69445937f6bbf"> 
<button type="button" class="btn btn-primary btn-cred btn-sm btn btn-default">Show</button> 
</a> 
</td> 
</tr> 
<tr> 
<td valign="middle"> 
<a href="/info/CCcam/palacio.iptv.re_1122_uxftgm1p_palacio/c3dbaa129dccbff15eeb7e4d6cd7d7210df38099" title="View line details for free Cline C: palacio.iptv.re 1122 uxftgm1p palacio">C: palacio.iptv.re 1122 uxftgm1p palacio</a> 
</td> 
<td class="text-center"> 
<span class="span_tooltip glyphicon glyphicon-remove-sign status_icon_offline" data-toggle="tooltip" rel="tooltip" data-placement="left" title="CCcam server down or invalid cline credentials"></span> 
</td> 
<td align="center" valign="middle"> 
<a href="/info/CCcam/palacio.iptv.re_1122_uxftgm1p_palacio/c3dbaa129dccbff15eeb7e4d6cd7d7210df38099"> 
<button type="button" class="btn btn-primary btn-cred btn-sm btn btn-default">Show</button> 
</a> 
</td> 
</tr> 
+0

'sed'の代わりに' grep'を使用します..... 'cat test.txt | grep -o '"> C \(。* \)" –

+0

あなたは何を求めているのですか? "オンラインCLINE"のような用語を説明してください。 –

+0

答えは以下の通りです – Takashi

答えて

0

たぶん、あなたはこれを使用することができます。

awk '/<tr>/ {printf "\n%s\n",$0;next} {printf "%s ",$0}' test | grep -o -P '(?<=Cline).*(?=online)' | grep -o -P '.*(?=">C)' 

awkコマンド。ファイル内の<tr></tr>の間の行をマージします。

first grep; Clineとオンライン間のテキストのみを取得する

last grep; URL部分のみを取得する

テスト;

$ awk '/<tr>/ {printf "\n%s\n",$0;next} {printf "%s ",$0}' test | grep -o -P '(?<=Cline).*(?=online)' | grep -o -P '.*(?=">C)' 
C: free.cccamlux.co 21900 FREEAC5p08w cccamlux.com 
+0

ありがとうそれは完全に動作します! – Takashi

関連する問題