Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 31st August 2007, 16:49
clem_c_rock clem_c_rock is offline
Junior Member
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help w/ sed parsing special characters

Hello,

I'm trying to change the image paths in a directory of files.

My first question is that I'm trying to use this line to test the change in one file:


sed -e 's/images/http://cache.somewebsite.com/images' ajax_scaffold.css

When I try that I get this:

sed: 1: "s/images/http://cache.r ...": bad flag in substitute command: '/'

I did a test by running this:

sed -e 's/images/duh/' ajax_scaffold.css

and the output said the changes had worked but when I went to the actual file, the changes didn't show?


Also, when I find a command that works, is it possible to specify a directory

and run this command on every file w/in the directory?
Reply With Quote
Sponsored Links
  #2  
Old 1st September 2007, 12:25
ghostdog74 ghostdog74 is offline
Junior Member
 
Join Date: Aug 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you escape the slashes...
Code:
sed -e "s/images/http:\/\/cache.somewebsite.com\/images/" file
Reply With Quote
  #3  
Old 6th September 2007, 18:35
clem_c_rock clem_c_rock is offline
Junior Member
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

hello, and thanks for your help.


this is the solution that worked for me:

Code:
for file in *; do
    sed -e 's/\/images/http:\/\/cache\.reverbnation\.com\/images/g' "$file" > "${file}.sub"
    rm "$file"
    mv "${file}.sub" "${file}"
done
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passwords: special characters? which ones? ./w Installation/Configuration 2 2nd June 2007 12:10
Apache2 Freezes celtic Server Operation 31 28th May 2007 18:18
Server does not accept French characters main3 Installation/Configuration 3 13th September 2006 10:21
strange characters in blog m u r Installation/Configuration 4 17th March 2006 14:18
Strange characters m u r Installation/Configuration 1 16th March 2006 19:14


All times are GMT +2. The time now is 16:38.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.