sed 's/foobar/$string/g'.... can't do this?

Dewey Paciaffi eddjp at edi386.UUCP
Fri Jan 18 01:25:42 AEST 1991


In article <1991Jan17.003856.469 at unicorn.cc.wwu.edu> n8743196 at unicorn.cc.wwu.edu (Jeff Wandling) writes:
-
-I tried:
-
-set string = newfoobar
-cat file | sed 's/foobar/$string/g' ....
-
-Is there a way for sed to use something like `echo $string` instead 
-of "$string" ??
-

You might try this :

	string=newfoobar
	cat file | sed 's/foobar/'$string'/g' ...

Note that you don't want to use the set command to set the variable,
and by using the additional single quotes in the sed command, the shell
can replace the $string variable.
-- 
Dewey Paciaffi           ...!uunet!edi386!eddjp



More information about the Comp.unix.shell mailing list