Sed Help.....

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Nov 10 22:13:17 PST 2004


On 2004-11-10 15:15, Rod Person <personrp at hotpop.com> wrote:
> On Wednesday 10 November 2004 7:58 pm, mailing lists at MacTutor wrote:
> > Take a look at what the shell replacement is actually doing. If you
> > were to write the line manually it would look like this:
> >
> > sed -e 's/\/usr\X11R6\/bin\/xdm/\/usr\/local\/bin\/kdm/g' ...
> >
> > Right?
> >
> > But the shell doesn't escape the path separators (slashes). You need to
> > escape them yourself in the variable assignments. Like this,
> >
> > KDMLINE='\/usr\/local\/bin\/kdm'
> > &c
>
> I hate when you look at something for hours and it something you know you
> should have known! I had at one point had the variables with double qoute and
> even tried to escape the qoutes!!

You can also use different sed-separator characters:

	sed -e "s|${REPLACELINE}|${KDMLINE}|"

The choise of '|' is arbitrary above.  It could have been '@', '#', or
'!', for all that sed(1) cares.  The substitution would still work.



More information about the freebsd-questions mailing list