Results 1 to 2 of 2
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 ...
- 08-31-2007 #1Just Joined!
- Join Date
- Jul 2004
- Posts
- 24
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?
- 08-31-2007 #2
The problem with your sed command is that in sed, the '/' character indicates the delimiter of the sections. If you want to use '/' inside the pattern or replacement, you need to escape it, so that your line looks like:
(that is, every '/' preceded by a '\')Code:sed -e 's/images/http:\/\/cache.somewebsite.com\/images' ajax_scaffold.css
As for doing it to every file in a directory, just do:
The /* means "all files inside the directory".Code:sed -e 'PATTERN' directory/*
DISTRO=Arch
Registered Linux User #388732


Reply With Quote