如何在shell中注释掉xml文件中的字符串 [英] How to comment out a string in xml file in shell

查看:60
本文介绍了如何在shell中注释掉xml文件中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE sailpoint PUBLIC 'sailpoint.dtd' 'sailpoint.dtd'>
<sailpoint>
<ImportAction name='include' value='custom/Application/CARD/CommonCardFiles/COF Imaging Applications Custom Object.xml'/>
<ImportAction name='include' value='custom/Configuration/COF - Singlenter code heree Entitlement Application Custom Object.xml'/>
<ImportAction name='include' value='custom/Rule/COF Related Application Library.xml'/>
<ImportAction name='include' value='custom/Form/COF LCM CBT Form.xml'/>
<ImportAction name='include' value='custom/Workflow/COF Identity Refresh Bypass.xml'/>
<ImportAction name='include' value='custom/Configuration/COF Unstable Roles Config.xml'/>
<ImportAction name='include' value='custom/Application/CARD/CommonCardFiles/COF Salesforce Common Correlation Rule.xml'/>
<ImportAction name='include' value='custom/Rule/COF Single SOD Violation Detection Rule.xml'/>
<ImportAction name='include' value='custom/Configuration/COF APPLICATION DEPENDENCY 
</sailpoint>*

在上面提到的代码中,我试图注释掉所有带有模式自定义/应用程序的行

On above mention code i am trying to comment out all the line with pattern custom/Application in it

我使用的 sed 命令不起作用

sed command i use that is not working

sed '/<custom&Application>/s/\(.*\)/<--\1-->/' est.xml > new.xml

推荐答案

这应该可行

sed -e '/custom\/Application/s/\(^.*$\)/<!--\1-->/' est.xml >new.xml

这篇关于如何在shell中注释掉xml文件中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆