请帮忙!我花了几个小时寻找我的解决方案,我的头撞到了墙上......我想要使用 sed 做的就是:查找包含“Number Deleted”字符串的标签,然后将其删除
输入:
<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
}