我有大约 100 个 xml 文件,其中在如何将欧元符号 (€) 显示为字符或 ( &euro
) 方面存在不一致。
首先要证明这两个字符串出现在同一个文件中,我使用了 grep :
grep -e "&euro" -e "€" -R /home/xml/ -o
&euro
只出现在标签 <conditions>
之间和 <directions>
.
例如
<directions> text text text : price : 19.99 &euro text text&euro </directions>
<conditions><tag><tag2> text text text &euro text&euro </tag2></tag></conditions>
我想在这些标签之间的任何字符串中搜索 € 符号的出现。
我怎样才能做到这一点?
最佳答案
下面是我如何使用元素“directions”:
find . -name "*.xml" | xargs grep "<directions>.*\&euro.*<\/directions>"
同样适用于“条件”元素。
关于xml - 如何在多个 xml 文件中搜索 linux 中两个标签之间出现的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22894619/