|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > More sed questions |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|