Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!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: <136@edi386.UUCP> Date: 22 Jan 91 14:03:03 GMT References: <1991Jan17.003856.469@unicorn.cc.wwu.edu> <135@edi386.UUCP> <1991Jan21.124531.27867@siesoft.co.uk> Reply-To: eddjp@edi386.UUCP ( Dewey Paciaffi ) Distribution: comp Organization: J.M. Huber Corp., Edison,NJ Lines: 38 In article <1991Jan21.124531.27867@siesoft.co.uk> stuart@siesoft.co.uk (Stuart Hood) writes: >eddjp@edi386.UUCP ( Dewey Paciaffi ) writes: - ->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' .... ->- - ->You might try this : - -> string=newfoobar -> cat file | sed 's/foobar/'$string'/g' ... - -Small point, to be safe you should do: - -cat file | sed 's/foobar/'"$string"'/g' ... - Point taken. >which doesn't fall over if "$string" has any whitespace in it. > >>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. > >Why can't you use the set command? My mistake. There isn't any reason you can't when using the csh, as many have pointed out to me since. -- Dewey Paciaffi ...!uunet!edi386!eddjp