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



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

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 10:47 AM.
 
Old 06-05-2011, 10:39 AM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,600
Blog Entries: 1

Rep: Reputation: 1046Reputation: 1046Reputation: 1046Reputation: 1046Reputation: 1046Reputation: 1046Reputation: 1046Reputation: 1046
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, 10:48 AM   #3
brainAcid
LQ Newbie
 
Registered: May 2011
Posts: 15

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, 11:24 AM   #4
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,692

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
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


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


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

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