Hi,
I have this text in a file where I need to move part of the text....
<Relation1 OriginatingObjectID="Holding_1" RelatedObjectID="Party_1" id="Relation_1">
<OriginatingObjectType tc="4">Holding</OriginatingObjectType>
<RelatedObjectType tc="6">Party</RelatedObjectType>
<RelationRoleCode tc="32">Insured</RelationRoleCode>
</Relation1>
<Relation2 OriginatingObjectID="Holding_2" RelatedObjectID="Party_2" id="Relation_2">
<OriginatingObjectType tc="4">Holding</OriginatingObjectType>
<RelatedObjectType tc="6">Party</RelatedObjectType>
<RelationRoleCode tc="32">Insured</RelationRoleCode>
</Relation2>
I want only the first line of each block in this text to be modified to
<Relation1 id="Relation_1" OriginatingObjectID="Holding_1" RelatedObjectID="Party_1">
similarly for second block ..
<Relation1 id="Relation_2" OriginatingObjectID="Holding_2" RelatedObjectID="Party_2">
and so on....
I tried it this way but could not get the complete solution...
grep "Relation1 " New_Text.txt | awk '{ print "<Relation " $4" "$2" "$3">"}'
but The result is ..
<Relation id="Relation_1"> OriginatingObjectID="Holding_1" RelatedObjectID="Party_1">
I do not want "id="Relation_1"> " instead I want id="Relation_1" This ">"should not appear after "Relation_1"...and how do I implement it in a text file where I have many blocks to be modified...and also have other blocks which does not need any change..?