我有一个包含以下内容的文件 test.xml:
<body>
<content>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam.</p><p>Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi,..</p><p>
<MEDIAREF localid="HTM37c2ae34-b92c-11e1-86ab-e6b6e8e434a7-0"/>
</p><p>Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue</p><p>
<MEDIAREF localid="HTM37c2ae34-b92c-11e1-86ab-e6b6e8e434a7-1"/>
</p><p>Praesent egestas leo in pede. Praesent blandit odio eu enim.
</p>
</content>
</body>
...
<ZONEMEDIAS>
<MEDIA localid="HTM37c2ae34-b92c-11e1-86ab-e6b6e8e434a7-0">
<MEDIAPROPRIETES>
<PROPRIETE value="HTM" name="type"/>
</MEDIAPROPRIETES>
<CODEMEDIA><object width="493" height="370"><param name="movie" value="http://www.youtube.com/v/Rxxxxxfr_FR&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/RxxxxxfrR&amp;rel=0" type="application/x-shockwave-flash" width="493" height="370" allowscriptaccess="always" allowfullscreen="true"></embed></object>
</CODEMEDIA>
</MEDIA><MEDIA localid="HTM37c2ae34-b92c-11e1-86ab-e6b6e8e434a7-1">
<MEDIAPROPRIETES>
<PROPRIETE value="HTM" name="type"/>
</MEDIAPROPRIETES>
<CODEMEDIA><blockquote class="twitter-tweet" lang="fr"><p>second texte to replace <a href="https://twitter.com/xxxx" data-datetime="2012-06-15T01:12:03+00:00">Juin 15, 2012</a></blockquote>
<script src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
</CODEMEDIA>
</MEDIA>
</ZONEMEDIAS>
我希望更换
<MEDIAREF localid="HTM37c2ae34-b92c-11e1-86ab-e6b6e8e434a7-0"/>
经过
<object width="493" height="370"><param name="movie" value="http://www.youtube.com/v/Rxxxxxfr_FR&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/RxxxxxfrR&amp;rel=0" type="application/x-shockwave-flash" width="493" height="370" allowscriptaccess="always" allowfullscreen="true"></embed></object>
并对 :: 做同样的事情
请问有什么方法可以在bash中实现这一点吗?
如果localid,我尝试了类似的方法来检索值
grep "<MEDIAREF localid=.*\".>" test.xml | sed -e "s/^.*<MEDIAREF localid=/<MEDIAREF localid=/" | cut -f2 -d"\"" | cut -f1 -d"\""
但我不知道如何更换之后
有人可以帮助我吗?