[comp.unix.questions] using variable in a regular expression

chris@mcc.UUCP (Chris Robertson) (05/01/90)

In article <6400@star.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes:
>In article <6358@star.cs.vu.nl> I wrote:
[Re using a shell variable in a sed expression]
>)...  What would happen if $1 were to contain a slash?
>)I guess sed wouldn't be so pleased with that.

In order to avoid this, make your sed delimiters something uncommon,
like ^A, or my own favourite, ^V.  Or even some fairly ordinary character
not likely to occur in a variable, like ";" -- e.g.:

	sed -e ";$original;$new;" $file > $newfile

Most sed's I've encountered will accept this.

-- 
"Down in the dumps?  I TOLD you you'd     |    Chris Robertson
 need two sets..."                        |  chris@mcc.pyrsyd.oz