Hi All,
please suggest me..
How to add the text from one file to another file and need to add the code after 3 lines of below searched line .
sample code in standard file:
<corecom:Description xml:id="id_2607">
<xsl:value-of select="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:Description" xml:id="id_2608"/>
</corecom:Description>
</xsl:if>
</corecom:ItemIdentification>
<xsl:if test="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:LifecyclePhase" xml:id="id_2609"> ---- Searched line..
<xsl:variable name="varItemLifeCyclePhase" xml:id="id_2610">
<xsl:value-of select="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:LifecyclePhase" xml:id="id_2611"/>
</xsl:variable>
---- Here We need to add the custom code from custom file-----
<!--SGI: customization for Lifecyclephase begin-->
<RemanFlagVal>
<xsl:value-of select="/changeABO:AffectedItem/changeABO:PageTwo/List22"/>
</RemanFlagVal>
RudiC
June 5, 2013, 3:42pm
2
Sorry - not the slightest clue what you are talking of. Please provide input and desired output samples, and whatever you have tried so far, plus explain the logics in plain English.
Sounds like copy the file and insert the 4 lines after some part of the XML. We can assume the XML will line-fold as shown always, I guess.
sed '
/<xsl:if test="\.\/changeABO:AffectedItem\/changeABO:TitleBlock\/itemABO:LifecyclePhase" xml:id="[^"]*">/{
:loop
/<\/xsl:variable>/!{
N
b loop
}
s/$/\
<!--SGI: customization for Lifecyclephase begin--> \
<RemanFlagVal> \
<xsl:value-of select="\/changeABO:AffectedItem\/changeABO:PageTwo\/List22"\/>\
<\/RemanFlagVal>/
}
' infile >outfile
Yoda
June 5, 2013, 5:32pm
5
Here is an approach using awk:
awk '/Search String/{R=NR}(NR-R)==3&&R{$0="Custom Code" RS $0;R=0}1' file
thanks for reply.
But we can copy the code from customfile to standard file.
awk '/"<xsl:if test="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:LifecyclePhase""/{R=NR}
(NR-R)==3&&R{$0="echo `cat /home/oracle/DBA/sh/need2add.txt`" RS $0;R=0}1' AgileCreateEngineeringChangeOrderListABM_to_CreateEngineeringChangeOrderListEBM.xsl
Above command is modified and pasted .
1)Is it correct?
please suggest..
---------- Post updated at 03:59 AM ---------- Previous update was at 03:49 AM ----------
I have executed above command , getting below error .
oracle@dv-agiledb01-dc21:~/DBA/sh> sh -x 1.sh
+ awk '"/<xsl:if test="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:LifecyclePhase"/{R=NR}(NR-R)==3&&R{$0="cat /home/oracle/DBA/sh/need2add.txt" RS $0;R=0}1' AgileCreateEngineeringChangeOrderListABM_to_CreateEngineeringChangeOrderListEBM.xsl
awk: "/<xsl:if test="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:LifecyclePhase"/{R=NR}(NR-R)==3&&R{$0="cat /home/oracle/DBA/sh/need2add.txt" RS $0;R=0}1
awk: ^ syntax error
awk: "/<xsl:if test="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:LifecyclePhase"/{R=NR}(NR-R)==3&&R{$0="cat /home/oracle/DBA/sh/need2add.txt" RS $0;R=0}1
awk: ^ syntax error
awk: "/<xsl:if test="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:LifecyclePhase"/{R=NR}(NR-R)==3&&R{$0="cat /home/oracle/DBA/sh/need2add.txt" RS $0;R=0}1
awk: ^ syntax error
awk: "/<xsl:if test="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:LifecyclePhase"/{R=NR}(NR-R)==3&&R{$0="cat /home/oracle/DBA/sh/need2add.txt" RS $0;R=0}1
awk: ^ syntax error
awk: "/<xsl:if test="./changeABO:AffectedItem/changeABO:TitleBlock/itemABO:LifecyclePhase"/{R=NR}(NR-R)==3&&R{$0="cat /home/oracle/DBA/sh/need2add.txt" RS $0;R=0}1
awk: ^ unterminated string