LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Closed Thread
 
Search this Thread
Old 05-04-2009, 02:49 PM   #1
lokeshn05
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
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...
 
Old 05-04-2009, 02:53 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
Quote:
STUDENT while filling your online registration, you will find
You really ought to do your own homework if you expect to learn anything.
 
Old 05-04-2009, 03:20 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
Have you read the documentation for SED and AWK?
 
Old 05-06-2009, 04:01 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
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.
 
  


Closed Thread

Tags
homework


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to replace line of file with another line using awk in shell script amit_pansuria Programming 3 03-29-2009 10:43 AM
complicated pattern matching with awk or sed... alirezan1 Linux - Newbie 1 10-10-2008 07:45 PM
simple pattern match with awk, sed alenD Linux - Newbie 10 03-10-2008 03:31 PM
How to get the pattern using sed or awk? ahpin Programming 3 08-02-2007 04:16 AM
replacement with sed: replace pattern with multiple lines Hcman Programming 5 11-18-2004 08:40 AM


All times are GMT -5. The time now is 06:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration