Skip to content
Advertisement

How to comment out a string in xml file in shell

<?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 command i use that is not working

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

Advertisement

Answer

This should work

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

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement