extract till occurance of a string

hi ,
i have an xml that comes in a single, the entire xml file is read as a single line when i open in edit plus or unix. i need to amend the contents of this xml file.

below is the extract from the file

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1"><data><IntegratedSite xmlns="http:google.com"><Pattern><BladeSystem><name>SIS</name><alias>SIS</alias><swgRef xmlns:IntegratedSite="http://www.google.com">/IntegratedSite:IntegratedSite/IntegratedSite:Software/IntegratedSite:SoftwareInventory/IntegratedSite:SoftwareGroup[IntegratedSite:prodNo="CXS10138"][IntegratedSite:prodRev="R4L06"]</swgRef>

I need to append <Is> before the occurance of tag <Pattern> ..

i tried the below but it did not work ..

sed -e 's/<Pattern>/<Is><Pattern>/' file >file1.

but it is generating file1 with zero byte for some reason .. Please suggest what could be done here.

Strange, but the same is working OK with me. Try like this:

 
sed -e 's!<Pattern>!<Is><Pattern>!' file > file1

Please note that if the file is from windows you need to check for carriage returns and try dos2unix.

Did you verify that the blue marked part of the command works, respectively prints some output :confused:

i tried that command with dummy input files, they replace the string <Pattern> with <Is><Pattern> but when i try it on the xml file then it is not giving any output.

i tried the below ... but that is also generating a file with zero byte

sed -e 's!<Pattern>!<Is><Pattern>!' file > file1

What does it give:

perl -ne '/...Pattern.../;print $&' file | od -c
0000000   s   >   <   P   a   t   t   e   r   n   >   <   B
0000015

this was the output for that i got for that perl command.