助けてください!私は自分の魂を探すのに何時間も費やしました、そして私は頭で壁にぶつかっています... sedを使ってやりたいのは:「削除された番号」文字列を含むタグを見つけてそれを削除することです
入力:
<Cell ss:StyleID="s128"/>
<Cell ss:StyleID="s128"/>
</Row>
<Row ss:AutoFitHeight="0">
<Cell ss:StyleID="s81"><Data ss:Type="String">Number Deleted</Data></Cell>
<Cell ss:StyleID="s81"/>
<Cell ss:StyleID="s81"/>
<Cell ss:StyleID="s81"/>
<Cell ss:StyleID="s82"><Data ss:Type="Boolean">0</Data></Cell>
<Cell ss:StyleID="s81"/>
<Cell ss:StyleID="s82"><Data ss:Type="Boolean">0</Data></Cell>
<Cell ss:StyleID="s83"><Data ss:Type="String">-1</Data></Cell>
<Cell ss:StyleID="s81"><Data ss:Type="String">"Deleted:"</Data></Cell>
<Cell ss:StyleID="s81"/>
<Cell ss:StyleID="s81"/>
<Cell ss:StyleID="s81"/>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Number Saved</Data></Cell>
<Cell ss:Index="5"><Data ss:Type="Boolean">0</Data></Cell>
<Cell ss:Index="7"><Data ss:Type="Boolean">0</Data></Cell>
出力:
<Cell ss:StyleID="s128"/>
<Cell ss:StyleID="s128"/>
</Row>
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Number Saved</Data></Cell>
<Cell ss:Index="5"><Data ss:Type="Boolean">0</Data></Cell>
<Cell ss:Index="7"><Data ss:Type="Boolean">0</Data></Cell>
これまでのところ、「削除された番号」からタグの終わりまでのxml除外行を表示する方法を理解しましたが、タグが閉じられていないため、これはxmlの整合性に問題があります。
function filter_xml
{
START="<Cell ss:StyleID="s81"><Data ss:Type="String">Number Deleted"
END="<\/Row>"
sed "/$START/,/$END/d" file.xml
}