1

I have an xml file where I need to insert a few lines at random places. I am trying to use sed/awk but running into some issues.

Here's what I am trying to do.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manager name="Manager1" exportDate="2020-01-13-05:00" comment=" configuration from 0.0.0.0">
    <ChannelSet>
        <ChannelEntry>
            <ChannelAttributesEntry name="/Pub/Sub/commands" TTL="0" capacity="0" EID="15" clusterWide="true" jmsEngine="true" mergeEngine="false" type="RELIABLE_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Web Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="false" groupname="Messenger Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
        <ChannelEntry>
           <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="true" groupname="Highland Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Aus Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Q Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
    <QueueSet>
        <QueueEntry>
            <ChannelAttributesEntry name="/3m/receive/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry HonorCapacityWhenFull="false" CacheOnReload="false"/>
            <QueuePermissionSet>
                <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" host="*" name="lijhlkjnlkjhlk"/>
                <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="true" pop="false" host="*" name="eeff456987987"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="false" pop="true" groupname="3m Group"/>
            </QueuePermissionSet>
        </QueueEntry>
        <QueueEntry>
            <ChannelAttributesEntry name="/7m/receive/fault/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false"/>
        </QueueEntry>
       <QueueEntry>
            <ChannelAttributesEntry name="/Orchestration/bigData/fault/gen" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false"/>
            <QueuePermissionSet>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="Big Data Group"/>
            </QueuePermissionSet>
        </QueueEntry>

I am trying to insert lines

                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>

in each of the queue entry.

So my final doc should look like

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manager name="Manager1" exportDate="2020-01-13-05:00" comment=" configuration from 0.0.0.0">
    <ChannelSet>
        <ChannelEntry>
            <ChannelAttributesEntry name="/Pub/Sub/commands" TTL="0" capacity="0" EID="15" clusterWide="true" jmsEngine="true" mergeEngine="false" type="RELIABLE_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Web Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="false" groupname="Messenger Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
        <ChannelEntry>
           <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="true" groupname="Highland Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Aus Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Q Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
    <QueueSet>
        <QueueEntry>
            <ChannelAttributesEntry name="/3m/receive/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry HonorCapacityWhenFull="false" CacheOnReload="false"/>
            <QueuePermissionSet>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>
                <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" host="*" name="lijhlkjnlkjhlk"/>
                <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="true" pop="false" host="*" name="eeff456987987"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="false" pop="true" groupname="3m Group"/>
            </QueuePermissionSet>
        </QueueEntry>
        <QueueEntry>
            <ChannelAttributesEntry name="/7m/receive/fault/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false"/>
            <QueuePermissionSet>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>
            </QueuePermissionSet>
        </QueueEntry>
       <QueueEntry>
            <ChannelAttributesEntry name="/Orchestration/bigData/fault/gen" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false"/>
            <QueuePermissionSet>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="Big Data Group"/>
            </QueuePermissionSet>
        </QueueEntry>

I tried using sed -i '/<QueuePermissionSet>/a\ followed by three lines' filename but that missing the one that does not have <QueuePermissionSet>.

I tried using awk but that isn't working either. Another idea i am testing is with a while loop check for the the line and insert line if match found. I am having issues inserting the lines at that particular point in the file.

Please help.

Daniel Haley
  • 51,389
  • 6
  • 69
  • 95
user2689092
  • 345
  • 2
  • 5
  • 13

2 Answers2

2

I wouldn't recommend doing this with sed/regex. (See related answer here.) That's probably why your question was edited to add the xmlstarlet tag.

If you're able to use xmlstarlet, what I would do is use the xmlstarlet tr command to do the transform with an XSLT.

In addition to an identity transform, you'd need two other templates. One to match an existing QueuePermissionSet and one to match a QueueEntry that doesn't already have a QueuePermissionSet.

Example...

xmlstarlet command line

xmlstarlet tr so.xsl input.xml > output.xml

XML Input (input.xml)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manager name="Manager1" exportDate="2020-01-13-05:00" comment=" configuration from 0.0.0.0">
    <ChannelSet>
        <ChannelEntry>
            <ChannelAttributesEntry name="/Pub/Sub/commands" TTL="0" capacity="0" EID="15" clusterWide="true" jmsEngine="true" mergeEngine="false" type="RELIABLE_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Web Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="false" groupname="Messenger Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
        <ChannelEntry>
            <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="true" groupname="Highland Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Aus Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Q Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
        <QueueSet>
            <QueueEntry>
                <ChannelAttributesEntry name="/3m/receive/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
                <StorePropertiesEntry HonorCapacityWhenFull="false" CacheOnReload="false"/>
                <QueuePermissionSet>
                    <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" host="*" name="lijhlkjnlkjhlk"/>
                    <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="true" pop="false" host="*" name="eeff456987987"/>
                    <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="false" pop="true" groupname="3m Group"/>
                </QueuePermissionSet>
            </QueueEntry>
            <QueueEntry>
                <ChannelAttributesEntry name="/7m/receive/fault/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
                <StorePropertiesEntry CacheOnReload="false"/>
            </QueueEntry>
            <QueueEntry>
                <ChannelAttributesEntry name="/Orchestration/bigData/fault/gen" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
                <StorePropertiesEntry CacheOnReload="false"/>
                <QueuePermissionSet>
                    <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="Big Data Group"/>
                </QueuePermissionSet>
            </QueueEntry>
        </QueueSet>
    </ChannelSet>
</Manager>

XSLT 1.0 (so.xsl)

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output indent="yes" encoding="UTF-8" standalone="yes"/>
  <xsl:strip-space elements="*"/>

  <xsl:variable name="entries">
    <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
    <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
    <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>
  </xsl:variable>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="QueuePermissionSet">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:copy-of select="$entries"/>
      <xsl:apply-templates select="node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="QueueEntry[not(QueuePermissionSet)]">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
      <QueuePermissionSet>
        <xsl:copy-of select="$entries"/>        
      </QueuePermissionSet>
    </xsl:copy>  
  </xsl:template>

</xsl:stylesheet>

XML Output (output.xml)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manager name="Manager1" exportDate="2020-01-13-05:00" comment=" configuration from 0.0.0.0">
  <ChannelSet>
    <ChannelEntry>
      <ChannelAttributesEntry name="/Pub/Sub/commands" TTL="0" capacity="0" EID="15" clusterWide="true" jmsEngine="true" mergeEngine="false" type="RELIABLE_TYPE"/>
      <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
      <ChannelPermissionSet>
        <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
        <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Web Group"/>
        <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="false" groupname="Messenger Group"/>
        <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
      </ChannelPermissionSet>
    </ChannelEntry>
    <ChannelEntry>
      <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
      <ChannelPermissionSet>
        <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
        <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="true" groupname="Highland Group"/>
        <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Aus Group"/>
        <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Q Group"/>
        <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
      </ChannelPermissionSet>
    </ChannelEntry>
    <QueueSet>
      <QueueEntry>
        <ChannelAttributesEntry name="/3m/receive/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
        <StorePropertiesEntry HonorCapacityWhenFull="false" CacheOnReload="false"/>
        <QueuePermissionSet>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>
          <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" host="*" name="lijhlkjnlkjhlk"/>
          <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="true" pop="false" host="*" name="eeff456987987"/>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="false" pop="true" groupname="3m Group"/>
        </QueuePermissionSet>
      </QueueEntry>
      <QueueEntry>
        <ChannelAttributesEntry name="/7m/receive/fault/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
        <StorePropertiesEntry CacheOnReload="false"/>
        <QueuePermissionSet>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>
        </QueuePermissionSet>
      </QueueEntry>
      <QueueEntry>
        <ChannelAttributesEntry name="/Orchestration/bigData/fault/gen" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
        <StorePropertiesEntry CacheOnReload="false"/>
        <QueuePermissionSet>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>
          <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="Big Data Group"/>
        </QueuePermissionSet>
      </QueueEntry>
    </QueueSet>
  </ChannelSet>
</Manager>
Daniel Haley
  • 51,389
  • 6
  • 69
  • 95
1

You really only need to find the file(s) in question and exec a sed command.

Run this command from the directory that the file is in:

find ./yourfile.xml -type f -readable -writable -exec sed -i "s/<QueuePermissionSet>/<QueuePermissionSet>\n\t\t<QueueGroupACLEntry listACLEntries=\"false\" modifyACLEntries=\"false\" fullControl=\"true\" purge=\"false\" peek=\"false\" push=\"false\" pop=\"false\" groupname=\"Admin Group\"\/>\n\t\t<QueueGroupACLEntry listACLEntries=\"false\" modifyACLEntries=\"false\" fullControl=\"false\" purge=\"false\" peek=\"false\" push=\"true\" pop=\"false\" groupname=\"SBGroup\"\/>\n\t\t<QueueGroupACLEntry listACLEntries=\"false\" modifyACLEntries=\"false\" fullControl=\"false\" purge=\"false\" peek=\"true\" push=\"false\" pop=\"false\" groupname=\"SMS Admin\"\/>\n/g" {} \;

I know it looks messy on a single line .. But .. You need to escape the quotes \" , as well as escape the slash on the closing of tags \/> I also took liberty of adding newlines \n and tabs \t to keep your formatting straight.

TESTED:

Before:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manager name="Manager1" exportDate="2020-01-13-05:00" comment=" configuration from 0.0.0.0">
    <ChannelSet>
        <ChannelEntry>
            <ChannelAttributesEntry name="/Pub/Sub/commands" TTL="0" capacity="0" EID="15" clusterWide="true" jmsEngine="true" mergeEngine="false" type="RELIABLE_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Web Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="false" groupname="Messenger Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
        <ChannelEntry>
           <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="true" groupname="Highland Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Aus Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Q Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
    <QueueSet>
        <QueueEntry>
            <ChannelAttributesEntry name="/3m/receive/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry HonorCapacityWhenFull="false" CacheOnReload="false"/>
            <QueuePermissionSet>
                <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" host="*" name="lijhlkjnlkjhlk"/>
                <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="true" pop="false" host="*" name="eeff456987987"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="false" pop="true" groupname="3m Group"/>
            </QueuePermissionSet>
        </QueueEntry>
        <QueueEntry>
            <ChannelAttributesEntry name="/7m/receive/fault/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false"/>
        </QueueEntry>
       <QueueEntry>
            <ChannelAttributesEntry name="/Orchestration/bigData/fault/gen" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false"/>
            <QueuePermissionSet>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="Big Data Group"/>
            </QueuePermissionSet>
        </QueueEntry>

After:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manager name="Manager1" exportDate="2020-01-13-05:00" comment=" configuration from 0.0.0.0">
    <ChannelSet>
        <ChannelEntry>
            <ChannelAttributesEntry name="/Pub/Sub/commands" TTL="0" capacity="0" EID="15" clusterWide="true" jmsEngine="true" mergeEngine="false" type="RELIABLE_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Web Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="false" groupname="Messenger Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
        <ChannelEntry>
           <StorePropertiesEntry CacheOnReload="false" Priority="1"/>
            <ChannelPermissionSet>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Admin Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="true" publish="false" useNamedSubcription="true" groupname="Highland Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Aus Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" getLastEID="true" purgeEvents="false" subscribe="false" publish="true" useNamedSubcription="false" groupname="Q Group"/>
                <ChannelGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" getLastEID="false" purgeEvents="false" subscribe="false" publish="false" useNamedSubcription="false" groupname="Retry Service Group"/>
            </ChannelPermissionSet>
        </ChannelEntry>
    <QueueSet>
        <QueueEntry>
            <ChannelAttributesEntry name="/3m/receive/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry HonorCapacityWhenFull="false" CacheOnReload="false"/>
            <QueuePermissionSet>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>

                <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" host="*" name="lijhlkjnlkjhlk"/>
                <QueueACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="true" pop="false" host="*" name="eeff456987987"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="false" pop="true" groupname="3m Group"/>
            </QueuePermissionSet>
        </QueueEntry>
        <QueueEntry>
            <ChannelAttributesEntry name="/7m/receive/fault/events" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false"/>
        </QueueEntry>
       <QueueEntry>
            <ChannelAttributesEntry name="/Orchestration/bigData/fault/gen" TTL="0" capacity="0" EID="0" clusterWide="true" jmsEngine="false" mergeEngine="false" type="PERSISTENT_TYPE"/>
            <StorePropertiesEntry CacheOnReload="false"/>
            <QueuePermissionSet>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="true" purge="false" peek="false" push="false" pop="false" groupname="Admin Group"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="SBGroup"/>
                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="true" push="false" pop="false" groupname="SMS Admin"/>

                <QueueGroupACLEntry listACLEntries="false" modifyACLEntries="false" fullControl="false" purge="false" peek="false" push="true" pop="false" groupname="Big Data Group"/>
            </QueuePermissionSet>
        </QueueEntry>
Zak
  • 6,976
  • 2
  • 26
  • 48
  • It failed to add the lines for the 7m/receive/fault/events. I was able achieve the same result as yours using sed. – user2689092 Jan 14 '20 at 00:29