Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) Newsgroups: comp.unix.shell Subject: Re: sed 's/foobar/$string/g'.... can't do this? Message-ID: <1991Jan23.044406.5075@NCoast.ORG> Date: 23 Jan 91 04:44:06 GMT References: <1991Jan17.003856.469@unicorn.cc.wwu.edu> <135@edi386.UUCP> <1991Jan21.124531.27867@siesoft.co.uk> Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) Followup-To: comp.unix.shell Distribution: comp Organization: North Coast Computer Resources (ncoast) Lines: 34 As quoted from <1991Jan21.124531.27867@siesoft.co.uk> by stuart@siesoft.co.uk (Stuart Hood): +--------------- | eddjp@edi386.UUCP ( Dewey Paciaffi ) writes: | >In article <1991Jan17.003856.469@unicorn.cc.wwu.edu> n8743196@unicorn.cc.wwu.edu (Jeff Wandling) writes: | >-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' ... | | >Note that you don't want to use the set command to set the variable, | Why can't you use the set command? +--------------- "Cultural differences". In csh, you *must* use "set"; in Bourne shell, you must *not* use it. As long as we're nit-picking: it's faster to say string=newfoobar # csh: set string = newfoobar sed 's/foobar/'"$string"'/g' < file because you don't have to start the "cat". ++Brandon -- Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440 Internet: allbery@NCoast.ORG Packet: KB8JRR @ WA8BXN America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88] uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY