Problem in Cut and paste

Hi,

I have a file like this -->
Consider z as space

#cat filename
ABC
<!--Nzzzzz-->
<!--RESUMO-->
EFG
XYZ
<!--Nzzzzz-->
<!--RESUMO-->

I need to cut the <!--RESUMO--> part and paste it to the previous line so that the file will look like this-->

ABC
<!--Nzzzzz--><!--RESUMO-->
EFG
XYZ
<!--Nzzzzz--><!--RESUMO-->

To replace with sed I have written a code but unfortunately it is not working. The code is-->

sed '/<\!\-\-N \-\-><\!\-\-RESUMO\-\->/!{ s/\/>/&\n/ }' | sed '/<\!\-\-N \-\-><\!\-\-RESUMO\-\->/!{s/>/&\n/}'

Can anyone help me on this?
I need to cut the part <!--RESUMO--> and paste it to the previous line

 
awk '!/\</{print a;print;a="";}/\</{a=a$0}END{if(a)print a}' input.txt

Hi itkamaraj,

The code you wrote is pulling all the lines into a single line.
I need only to pull <!--RESUMO--> part into its previous line and all other lines remain as it is.

try this...

awk '{if ($0 ~ /<!--N/) { x=$0;getline;y=$0; { if ( $0 ~ /-RESUMO-/ ) {  print x,y} else { print } } } else { print $0} } ' file2

Thanks a lot pamu...its working fine after a minor tuning-->

awk '{if ($0 ~ /<!--N/) { x=$0;getline;y=$0; { if ( $0 ~ /-RESUMO-/ ) {  print x,y} else { print } } } else { print $0} } ' SAM | sed 's/>.*</></g'