LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   sed question (https://www.linuxquestions.org/questions/programming-9/sed-question-288859/)

lazyuser 02-11-2005 05:48 AM

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

lazyuser 02-11-2005 06:02 AM

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

theYinYeti 02-11-2005 06:03 AM

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

Yves.

lazyuser 02-11-2005 06:05 AM

That worked, thank you very much.

Lazyuser

Hko 02-11-2005 06:11 AM

Two other, simpler, ways:
Code:

sed 's|^\x27|http://someurl.com|' file.txt
sed 's|^'\\''|http://someurl.com|' file.txt



All times are GMT -5. The time now is 08:32 AM.