[vox-tech] sed question
David Margolis
vox-tech@lists.lugod.org
Wed, 29 Oct 2003 20:06:38 -0800 (PST)
Hello,
I'm having trouble with escape characters while trying to substitute with
sed. Mostly it has to do with the forward slash itself.
Because of an automated process that generates webpages (but
misunderstands where some files are in relationship to roo), I end up with
some errors sometimes that look like this:
<a href="http://www.domain.com/somedir/somedir/page.htm">link</a>
What I really wanted, of course, was this:
<a href="http://www.domain.com/somedir/page.htm">link</a>
so i figured out by using 'sed s/somedir\\/somedir/somedir/g filename.htm
> tempfile.htm' does the trick.
My problem is that I don't know the value of 'somedir' as it is generated
from a shell script AND 'somedir' often has it's own '/'s in it like:
'/somedir/somesubdir'.
How do I do: 'sed s/$i\\/$i/$i/g' when $i might have it's own forward
slashes?
Or, if I'm way off base, please suggest an alternative approach (note: I
don't have access to PERL on the box in question).
Thanks,
Dave M.