Morning All,I'm new to UNIX so looking to do something I can do in VB but don't have the experience to do in UNIX.I have an xml spec on a share which requires regular deletion and updates as new reuters RIC codes come online. Two items to achieve:A. Remove a RIC entryOpen the fileFind a specific stringDelete this found line and the 21 lines below itSave fileI though this might work:sed e '/<ric id=AUG03250639E=YBAU>/,+21d'  a.xml >a.xmlB. Add a new RIC entryOpen a fileFind the last occurrence of the sting </source>Move up 29 lines to the last RIC entry block Copy this line and the 21 lines below (the ric block)Insert a new line 22 lines below and paste this bloc (a new block) i.e. directly below the block you copiedChange the ric on line 1 of the new block to a new Ric string i.e. <ricid=AAAAA=YBAU to <ricid=BBBBB=YBAUSave fileHow can I do this?This is the last section of the file. Note the end of the ric blocks (which I want to manipulate) is when the following strings appear  ...            <ric id=AUG03250639E=YBAU>                <securities>                    <security>                        <issueid>178117</issueid>                        <quote-type>YIELD</quote-type>                        <complex-logic>                            <calculations>                                <yield-type>                                    <type>BID_YIELD</type>                                    <calculation name=AB field=RT_YIELD_1 />                                </yield-type>                                <yield-type>                                    <type>OFFER_YIELD</type>                                    <calculation name=AB field=SEC_YLD_1 />                                </yield-type>                            </calculations>                        </complex-logic>                        <derived-type name=PRICE baseValue=100.0 />                    </security>                </securities>            </ric>            <ric id=AUG03250640E=YBAU>                <securities>                    <security>                        <issueid>178117</issueid>                        <quote-type>YIELD</quote-type>                        <complex-logic>                            <calculations>                                <yield-type>                                    <type>BID_YIELD</type>                                    <calculation name=AB field=RT_YIELD_1 />                                </yield-type>                                <yield-type>                                    <type>OFFER_YIELD</type>                                    <calculation name=AB field=SEC_YLD_1 />                                </yield-type>                            </calculations>                        </complex-logic>                        <derived-type name=PRICE baseValue=100.0 />                    </security>                </securities>            </ric>        </rics>        <topics>            <topic>                <id>default</id>                <type>rmds</type>                <value>IDN_SELECTFEED.ANY.%s.NaE</value>            </topic>        </topics>    </source>    <transformers>        <!-- Name of transformer -->        <transformer></transformer>    </transformers>    <processors>        <!-- Enricher to add additional fields from source query result while             publishing -->        <processor></processor>    </processors>    <endpoints>        <!-- Order of post processor is important. First topic, then mapper -->        <endpoint id=rmds topic=FI.ANY.%s.YBAU multicast=true>            <postprocessor>reuters-topic-builder</postprocessor>            <postprocessor>reuters-message-mapper</postprocessor>            <!-- <multitopic id=solace topic=LN/FI/IP/APS/SSHEET/YIELD/BATS_%s                 /> -->            <multitopic id=solace-credit topic=LN/FI/EP/CREDITBPS/SSHEET/BATS_%s />            <multitopic id=solace-credit topic=LN/FI/EP/CREDITBPS/YIELDBROKER/BATS_%s />        </endpoint>    </endpoints>    <other-properties>        <!-- common formatting of price/yield -->        <property name=formattor-1>(math:pow(INPUT/100+1,0.5)-1)*200</property>        <property name=handle_negative_values>false</property>        <property name=handle_negative_values_output>0.001</property>    </other-properties></specification>So for A. Remove a RIC entry where I want to remove AUG03250640E=YBAU, the file would show:            <ric id=AUG03250639E=YBAU>                <securities>                    <security>                        <issueid>178117</issueid>                        <quote-type>YIELD</quote-type>                        <complex-logic>                            <calculations>                                <yield-type>                                    <type>BID_YIELD</type>                                    <calculation name=AB field=RT_YIELD_1 />                                </yield-type>                                <yield-type>                                    <type>OFFER_YIELD</type>                                    <calculation name=AB field=SEC_YLD_1 />                                </yield-type>                            </calculations>                        </complex-logic>                        <derived-type name=PRICE baseValue=100.0 />                    </security>                </securities>            </ric>        </rics>        <topics>            <topic>                <id>default</id>                <type>rmds</type>                <value>IDN_SELECTFEED.ANY.%s.NaE</value>            </topic>        </topics>    </source>    <transformers>        <!-- Name of transformer -->        <transformer></transformer>    </transformers>    <processors>        <!-- Enricher to add additional fields from source query result while             publishing -->        <processor></processor>    </processors>    <endpoints>        <!-- Order of post processor is important. First topic, then mapper -->        <endpoint id=rmds topic=FI.ANY.%s.YBAU multicast=true>            <postprocessor>reuters-topic-builder</postprocessor>            <postprocessor>reuters-message-mapper</postprocessor>            <!-- <multitopic id=solace topic=LN/FI/IP/APS/SSHEET/YIELD/BATS_%s                 /> -->            <multitopic id=solace-credit topic=LN/FI/EP/CREDITBPS/SSHEET/BATS_%s />            <multitopic id=solace-credit topic=LN/FI/EP/CREDITBPS/YIELDBROKER/BATS_%s />        </endpoint>    </endpoints>    <other-properties>        <!-- common formatting of price/yield -->        <property name=formattor-1>(math:pow(INPUT/100+1,0.5)-1)*200</property>        <property name=handle_negative_values>false</property>        <property name=handle_negative_values_output>0.001</property>    </other-properties></specification>For B. Add a new RIC entry assuming I want to add the new ric AUG03250641E=YBAU, the file would show:            <ric id=AUG03250639E=YBAU>                <securities>                    <security>                        <issueid>178117</issueid>                        <quote-type>YIELD</quote-type>                        <complex-logic>                            <calculations>                                <yield-type>                                    <type>BID_YIELD</type>                                    <calculation name=AB field=RT_YIELD_1 />                                </yield-type>                                <yield-type>                                    <type>OFFER_YIELD</type>                                    <calculation name=AB field=SEC_YLD_1 />                                </yield-type>                            </calculations>                        </complex-logic>                        <derived-type name=PRICE baseValue=100.0 />                    </security>                </securities>            </ric>            <ric id=AUG03250640E=YBAU>                <securities>                    <security>                        <issueid>178117</issueid>                        <quote-type>YIELD</quote-type>                        <complex-logic>                            <calculations>                                <yield-type>                                    <type>BID_YIELD</type>                                    <calculation name=AB field=RT_YIELD_1 />                                </yield-type>                                <yield-type>                                    <type>OFFER_YIELD</type>                                    <calculation name=AB field=SEC_YLD_1 />                                </yield-type>                            </calculations>                        </complex-logic>                        <derived-type name=PRICE baseValue=100.0 />                    </security>                </securities>            </ric>            <ric id=AUG03250641E=YBAU>                <securities>                    <security>                        <issueid>178117</issueid>                        <quote-type>YIELD</quote-type>                        <complex-logic>                            <calculations>                                <yield-type>                                    <type>BID_YIELD</type>                                    <calculation name=AB field=RT_YIELD_1 />                                </yield-type>                                <yield-type>                                    <type>OFFER_YIELD</type>                                    <calculation name=AB field=SEC_YLD_1 />                                </yield-type>                            </calculations>                        </complex-logic>                        <derived-type name=PRICE baseValue=100.0 />                    </security>                </securities>            </ric>        </rics>        <topics>            <topic>                <id>default</id>                <type>rmds</type>                <value>IDN_SELECTFEED.ANY.%s.NaE</value>            </topic>        </topics>    </source>    <transformers>        <!-- Name of transformer -->        <transformer></transformer>    </transformers>    <processors>        <!-- Enricher to add additional fields from source query result while             publishing -->        <processor></processor>    </processors>    <endpoints>        <!-- Order of post processor is important. First topic, then mapper -->        <endpoint id=rmds topic=FI.ANY.%s.YBAU multicast=true>            <postprocessor>reuters-topic-builder</postprocessor>            <postprocessor>reuters-message-mapper</postprocessor>            <!-- <multitopic id=solace topic=LN/FI/IP/APS/SSHEET/YIELD/BATS_%s                 /> -->            <multitopic id=solace-credit topic=LN/FI/EP/CREDITBPS/SSHEET/BATS_%s />            <multitopic id=solace-credit topic=LN/FI/EP/CREDITBPS/YIELDBROKER/BATS_%s />        </endpoint>    </endpoints>    <other-properties>        <!-- common formatting of price/yield -->        <property name=formattor-1>(math:pow(INPUT/100+1,0.5)-1)*200</property>        <property name=handle_negative_values>false</property>        <property name=handle_negative_values_output>0.001</property>    </other-properties></specification>
Edit an xml file - Find a string then Delete a block of text / Find a string then Insert a new block of text
text processing;sed;xml