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