1
我有xml文件如下:AWK,不同的分隔符之间提取字符串
<Name ns1:translate="yes">Overview</Name>
<TextValue>Start</TextValue>
<Title ns1:translate="yes">This is a "book"</Title>
<Title>BOOK</Title>
<Description ns1:translate="yes"/>
<TextValue ns1:translate="yes">End</TextValue>
我想,如果标记包含翻译=“是”提取字符串。输出应该如下所示:
Overview = Overview
This is a "book" = This is a "book"
=
End = End
我需要使用shell脚本来完成上述提取。我试图使用:
awk awk -F '["<>]' '{if (/.*translate="yes".*/) {print ((NF>6?OFS $(NF-2):x))}
但它没有给我想要的结果,因为输出中的“书”没有被打印出来。请让我知道上述awk中会出现什么错误。
改为使用支持XML的工具,如'xsltproc'。 – tripleee