-   Linux - Newbie (
-   -   replace a pattern with a line using sed/awk (

lokeshn05 05-04-2009 02:49 PM

replace a pattern with a line using sed/awk
XML file:


<div style="position:absolute;left:314.81px;top:194.39px" class="cls_003">STUDENT while filling your online registration, you will find a</div>
<div style="position:absolute;left:39.65px;top:200.20px" class="cls_003">1</div>
<div style="position:absolute;left:50.18px;top:200.20px">
<span class="cls_005">PRINT this form </span>
<span class="cls_003">. Make sure you print pages 3 and 4 </span>

this is one of the example xml file.
i need to replace class="cls_003" with corresponding line in the comment for <div> tag
similarly for class="cls_005" in <span> tag, by include style attr instead of class in <span> tag

result should be like,

<div style="position:absolute;left:314.81px;top:194.39px;font-family:Arial,serif;font-size:9px;color:rgb(51,51,51);font-weight:normal;font-style:normal">STUDENT while filling your online registration, you will find a</div>

<div style="position:absolute;left:39.65px;top:200.20px;font-family:Arial,serif;font-size:9px;color:rgb(51,51,51);font-weight:normal;font-style:normal">1</div>

<div style="position:absolute;left:50.18px;top:200.20px">
<span style="font-family:Arial,serif;font-size:8px;color:rgb(51,51,51);font-weight:bold;font-style:normal">PRINT this form </span>

<span style="font-family:Arial,serif;font-size:9px;color:rgb(51,51,51);font-weight:normal;font-style:normal">. Make sure you print pages 3 and 4 </span>

plz do reply soon with the result using sed or awk

any response will be appreciated...

MensaWater 05-04-2009 02:53 PM


STUDENT while filling your online registration, you will find
You really ought to do your own homework if you expect to learn anything.

pixellany 05-04-2009 03:20 PM

Have you read the documentation for SED and AWK?

pixellany 05-06-2009 04:01 PM


plz do reply soon
24 hours later, it seems that this was really not that urgent for you.

I'm closing this, but please feel free to make a new thread with any more specific questions that come from reading the documentation.

All times are GMT -5. The time now is 02:10 AM.