UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 17th, 2006, 07:09 PM
kiarna kiarna is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2006
Posts: 2 kiarna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 7 sec
Reputation Power: 0
More sed questions

I posted this in an existing thread on sed but I don't know if anyone spotted it.....

GNU sed version 4.1.2
FC3 box.

I think it's a basic owee in the brain RE problem, but my ears are starting to bleed.

I'm trying to change listed images in an html file to reflect the relative path. The image names are multiple per file I only have the extension .jpg, .png, or .gif.

I tried doing:

sed 's|(.*\)\.png|upload\/images\/\1.png|g' filename > filename.tmp


and it places the new path 'upload/images/' at the beginning of the line rather than appending it to the image name.

any suggestions for what I'm maiming with my RE?

Thank ya!

XK

Reply With Quote
  #2  
Old May 18th, 2006, 08:58 AM
stanleypane's Avatar
stanleypane stanleypane is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Baltimore, MD
Posts: 208 stanleypane User rank is Sergeant (500 - 2000 Reputation Level)stanleypane User rank is Sergeant (500 - 2000 Reputation Level)stanleypane User rank is Sergeant (500 - 2000 Reputation Level)stanleypane User rank is Sergeant (500 - 2000 Reputation Level)stanleypane User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 7 h 4 m 19 sec
Reputation Power: 21
Your regex is searching for (.*\) right in the beginning. THis is causing sed to match ANY character from the beginning of the line up until it see's .png.

If it's an HTML file, I would assume the file paths are surrounded by quotes? If so, you can do this:
Code:
sed -e "s/\"\([0-9A-Za-z]*\).png\"/\"path\/to\/file\/\1\.png\"/g"

My, that's ugly heh. It'll work though.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > More sed questions


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT