skip to Main Content

I’m trying to automate how the Adobe CC Cleaner tool creates and then requires the administrator to uncomment specific lines or in our case all lines for each product for a full cleanup as instructed here for macOS.

I would like to know how to remove/uncomment <!-- which has leading whitespaces and --> on each product/line only without affecting the other lines.

Here an example of the output after generating the cleanup.xml file with the tool on Adobe CC 2020 products:

    <?xml version="1.0" encoding="UTF-8"?>
<Products>
    <Properties>
        <Property name="eulaAccepted">1</Property>
    </Properties>
    <CreativeCloud>
        <!--<Product productName="AdobeCreativeCloud" version="2.0"/>-->
        <!--<Product productName="After Effects" version="17.0.5"/>-->
        <!--<Product productName="Camera Raw" version="12.2"/>-->
        <!--<Product productName="STI_Color_MotionPicture_HD" version="1.2"/>-->
        <!--<Product productName="STI_ColorCommonSet_RGB_HD" version="1.1"/>-->
        <!--<Product productName="Bridge" version="10.0.3"/>-->
        <!--<Product productName="Illustrator" version="24.0.3"/>-->
        <!--<Product productName="CoreSync" version="4.3.34"/>-->
        <!--<Product productName="InDesign" version="15.0.2"/>-->
        <!--<Product productName="Photoshop" version="21.1.1"/>-->
        <!--<Product productName="HD_ASU" version="2.0"/>-->
        <!--<Product productName="Lightroom" version="3.2"/>-->
        <!--<Product productName="Media Encoder" version="14.0.4"/>-->
        <!--<Product productName="CCX Process" version="3.5.1"/>-->
        <!--<Product productName="Premiere Pro" version="14.0.4"/>-->
        <!--<Product productName="CC Library" version="3.7.4"/>-->
    </CreativeCloud>
    <AAM></AAM>
    <AdobeIdCredentials></AdobeIdCredentials>
    <CS6></CS6>
    <CS5></CS5>
    <CS4></CS4>
    <CS3></CS3>
</Products>

Tried following the instructions provided here and here doing the reverse with no luck. Any help on this will be greatly appreciated 🙌🏻

2

Answers


  1. Try

    using xmlstarlet

    xmlstarlet ed -d '//comment()' 
    

    using sed

    sed '/Product/ s#<!--##g;s#-->##g;'
    

    Demo:

    echo  '<!--<Product productName="AdobeCreativeCloud" version="2.0"/>-->' | sed '/Product/ s#<!--##g;s#-->##g;' 
    <Product productName="AdobeCreativeCloud" version="2.0"/>
    
    
    
    Login or Signup to reply.
  2. Assuming your real input is as simple and regular as you show in your example then with any sed you can do:

    $ sed 's/<!--(.*)-->/1/' file
        <?xml version="1.0" encoding="UTF-8"?>
    <Products>
        <Properties>
            <Property name="eulaAccepted">1</Property>
        </Properties>
        <CreativeCloud>
            <Product productName="AdobeCreativeCloud" version="2.0"/>
            <Product productName="After Effects" version="17.0.5"/>
            <Product productName="Camera Raw" version="12.2"/>
            <Product productName="STI_Color_MotionPicture_HD" version="1.2"/>
            <Product productName="STI_ColorCommonSet_RGB_HD" version="1.1"/>
            <Product productName="Bridge" version="10.0.3"/>
            <Product productName="Illustrator" version="24.0.3"/>
            <Product productName="CoreSync" version="4.3.34"/>
            <Product productName="InDesign" version="15.0.2"/>
            <Product productName="Photoshop" version="21.1.1"/>
            <Product productName="HD_ASU" version="2.0"/>
            <Product productName="Lightroom" version="3.2"/>
            <Product productName="Media Encoder" version="14.0.4"/>
            <Product productName="CCX Process" version="3.5.1"/>
            <Product productName="Premiere Pro" version="14.0.4"/>
            <Product productName="CC Library" version="3.7.4"/>
        </CreativeCloud>
        <AAM></AAM>
        <AdobeIdCredentials></AdobeIdCredentials>
        <CS6></CS6>
        <CS5></CS5>
        <CS4></CS4>
        <CS3></CS3>
    </Products>
    

    or if you really do need to only apply it to lines that start with spaces then using GNU or OSX/BSD sed for -E for EREs:

    sed -E 's/^([[:space:]]+)<!--(.*)-->/12/' file
    

    or with any POSIX sed:

    sed 's/^([[:space:]]{1,})<!--(.*)-->/12/' file
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search