LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-11-2005, 05:48 AM   #1
lazyuser
LQ Newbie
 
Registered: May 2004
Location: US
Distribution: Debian - Sarge
Posts: 15

Rep: Reputation: 0
sed question


Hello, I have a file which has lines like this
'/images/gallery/wow_yeah.jpg,

what I want to do is remove the ', and put in front a url, for example
http://madeup.com/images/gallery/wow_yeah.jpg,

I been messing around with sed and awk with no luck, and help would be appricated.

Have problems with (') character.

Lazyuser
 
Old 02-11-2005, 06:02 AM   #2
lazyuser
LQ Newbie
 
Registered: May 2004
Location: US
Distribution: Debian - Sarge
Posts: 15

Original Poster
Rep: Reputation: 0
I got this to print text into the front of my file,
sed 's/^/http:\/\/www.madeup.com/'

but how do I get rid of ', and my url Right now it looks like
http://www.madeup.com'/images/gallery/wow_yeah.jpg,
I want to get rid of the ',

Lazyuser
 
Old 02-11-2005, 06:03 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
sed "s|^[^/]*\\(/[^,]*\\),*\$|http://madeup.com\\1|"

Yves.
 
Old 02-11-2005, 06:05 AM   #4
lazyuser
LQ Newbie
 
Registered: May 2004
Location: US
Distribution: Debian - Sarge
Posts: 15

Original Poster
Rep: Reputation: 0
That worked, thank you very much.

Lazyuser
 
Old 02-11-2005, 06:11 AM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Two other, simpler, ways:
Code:
sed 's|^\x27|http://someurl.com|' file.txt
sed 's|^'\\''|http://someurl.com|' file.txt
 
  


Reply



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
sed question ckoniecny Linux - General 3 11-11-2005 09:31 AM
sed question sphynx Programming 6 04-28-2004 06:25 PM
little sed question freelinuxcpp Linux - Software 3 01-20-2004 07:36 AM
sed question zoomzoom Linux - Software 2 10-20-2003 04:04 PM
A question on 'sed' Barbarian Programming 4 04-11-2002 10:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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