Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!edi386!eddjp From: eddjp@edi386.UUCP ( Dewey Paciaffi ) Newsgroups: comp.unix.shell Subject: Re: sed 's/foobar/$string/g'.... can't do this? Keywords: sed Message-ID: <135@edi386.UUCP> Date: 17 Jan 91 14:25:42 GMT References: <1991Jan17.003856.469@unicorn.cc.wwu.edu> Reply-To: eddjp@edi386.UUCP ( Dewey Paciaffi ) Distribution: comp Organization: J.M. Huber Corp., Edison,NJ Lines: 21 In article <1991Jan17.003856.469@unicorn.cc.wwu.edu> n8743196@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