Re: vi and quoted strings ...
> 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 ?
>
> 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 ?
Is there a reason why you don't use sed? The s///-syntax
is the same as in vi, and you could easily wrap the sed-
command into a shell-script that performs a loop over all
your html files - like that:
for file in $(ls -1 --color=never *.html); do
cp $file $file.old;
sed -e "s/file:\/\/\/home\/web\/Desktop\/current\//g" $file.old > $file;
done
(makes a backup of the old htmls, if I've accidentally
included a syntax error)
Vi is the only text editor I'm using, but mass substitutions
like your problem could far easier be accomplished by a
stream editor like sed.
Reply to: