0

ファイルから特定のパターンを抽出しようとしています。ファイルの内容:

--------some other command in here----------
<tr>
<td>someWords</td>
<td>anotherWords</td>
</tr>
--------some other command in here-----------
the <tr>...</tr> patter occur again

ファイルからtrパターンを抽出しようとします

私が書くシェルスクリプトで:

入力を読む

grep '<tr>\n<td>[A-Za-z0-9,<,>,/]</td>\n<td>[A-Za-z0-9,<,>,/]</td>\n</tr>

ただし、このコマンドは機能しません。何か案が?どうも

4

1 に答える 1

0
 sed -n '/<tr>/,/<\/tr>/p' file

例を参照してください:

kent$  cat a                      
--------some other command in here----------
<tr>
<td>someWords</td>
<td>anotherWords</td>
</tr>
--------some other command in here-----------
the 
<tr>
<td>someOtherWords</td>
<td>anotherWords2</td>
</tr>

kent$  sed -n '/<tr>/,/<\/tr>/p' a
<tr>
<td>someWords</td>
<td>anotherWords</td>
</tr>
<tr>
<td>someOtherWords</td>
<td>anotherWords2</td>
</tr>
于 2013-01-18T23:12:49.430 に答える