LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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


Reply
  Search this Thread
Old 06-05-2011, 09:31 AM   #1
brainAcid
LQ Newbie
 
Registered: May 2011
Posts: 16

Rep: Reputation: Disabled
sed for HTML


Hello! Thanks for dropping by!

How do I tell sed to replace abc
with the patterns found in file list.txt?

Search:
Code:
<a href="abc">
Replace:
Code:
<a href="./Content/audio/Evening Darshan 090606.mp3">

This is what I have been doing:
Code:
sed '/\".*\"/{/\".*\"{R list.txt 

d}}' audio.txt > out.txt
My result is incorrect. Because I cant figure out the search expression.

Thanks for the help!

Last edited by brainAcid; 06-05-2011 at 09:47 AM.
 
Old 06-05-2011, 09:39 AM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
I'm not sure I understand what you are trying to achieve. Can you show us the original file and how it's supposed to look like after the substitution?
 
0 members found this post helpful.
Old 06-05-2011, 09:48 AM   #3
brainAcid
LQ Newbie
 
Registered: May 2011
Posts: 16

Original Poster
Rep: Reputation: Disabled
Source:
Code:
<a href="./Content/audio/769-chapter-13-five-potent-forms-of-devotional-service-part-1-w-video">Chapter 13: Five Potent Forms of Devotional Service</a>
Result:
Code:
<a href="./Content/audio/Evening Darshan 090606.mp3">
 
Old 06-05-2011, 10:24 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Well I would suggest that you will need to know what is the unique identifier of that line.
So if it was say the number 769, you could do:
Code:
sed -r -i.bak '/769/s/(audio/).*/\1Evening Darshan 090606.mp3">/' file
 
0 members found this post helpful.
  


Reply

Tags
sed



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
Newed a little help on using sed to insert html niknak Linux - Newbie 2 12-01-2009 09:21 AM
using sed to edit html tkeyser Programming 6 08-20-2009 07:15 PM
sed with html document jpgauvin Linux - Newbie 4 12-22-2008 06:54 PM
sed and html naflan Programming 1 01-10-2006 08:51 PM
convert html file to latex format using sed? BigHeadDog Linux - Newbie 2 12-01-2003 11:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:01 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
Open Source Consulting | Domain Registration