LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   replace a pattern with a line using sed/awk (https://www.linuxquestions.org/questions/linux-newbie-8/replace-a-pattern-with-a-line-using-sed-awk-723631/)

lokeshn05 05-04-2009 01:49 PM

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

<!--
span.cls_004{font-family:Arial,serif;font-size:12px;color:rgb(51,51,51);font-weight:normal;font-style:normal}
div.cls_004{font-family:Arial,serif;font-size:12px;color:rgb(51,51,51);font-weight:normal;font-style:normal}
span.cls_003{font-family:Arial,serif;font-size:9px;color:rgb(51,51,51);font-weight:normal;font-style:normal}
div.cls_003{font-family:Arial,serif;font-size:9px;color:rgb(51,51,51);font-weight:normal;font-style:normal}
span.cls_005{font-family:Arial,serif;font-size:8px;color:rgb(51,51,51);font-weight:bold;font-style:normal}
div.cls_005{font-family:Arial,serif;font-size:8px;color:rgb(51,51,51);font-weight:bold;font-style:normal}
-->


<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>
</div>


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>
</div>


plz do reply soon with the result using sed or awk

any response will be appreciated...

MensaWater 05-04-2009 01:53 PM

Quote:

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 02:20 PM

Have you read the documentation for SED and AWK?

pixellany 05-06-2009 03:01 PM

Quote:

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 09:43 AM.