Re: vi and quoted strings ...
Dave Selby <dave_arahan@yahoo.co.uk> writes:
> What I am trying to do is change an absolute HTML path to a relative
> one ... ie from
>
> file:///home/web/Desktop/current/jpegs/logo.jpeg
> to
>
> jpegs/logo.jpeg
>
> In vi the following usually works ...
> :1,$s/search text/replace text/g
>
> However because the search text has / in it it brings up the error
> message "trailing characters" I have tried quoting it in ' ' and " "
> same error message. - any ideas ?
As other people have pointed out, you either need to backslash-quote
your forward slashes or use a different delimiter. I believe pretty
much every implementation of ed, vi, sed, and perl all would support
:%s@file:///home/web/Desktop/current/@@g
> Also on subject of vi, Since I have a lot of pages to change and dont
> want to miss any, I used the format ..
>
> vi xxx.html xxxx.html xxxx.html .....
>
> and moved on with
> :n
>
> Is there a way to re-do my search string so I don't have to keep
> re-typing it in ?
If it were me, I'd write a shell script (or type in directly at the
command prompt) something like this:
for i in *.html; do
sed -e 's@file:///home/web/Desktop/current@@g' $i > $i.new && \
mv $i.new $i
done
Other people would use something like 'perl -pi.bak -e', but I can
never remember the command-line flags, and perl is huge for a simple
task like this anyways. :-)
--
David Maze dmaze@debian.org http://people.debian.org/~dmaze/
"Theoretical politics is interesting. Politicking should be illegal."
-- Abra Mitchell
Reply to: