[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] sed expression wildcard bafflement



on Fri, 17 Oct 2003 04:53:55PM -0400, Travis Crump insinuated:
> Nori Heikkinen wrote:
> >a friend just asked me about a shell script she's trying to write.
> >she's got a file that looks like this:
> >
> >  blah blah thi. blah thi. blah blah
> >  blah thi. blah thi. blah blah blah
> >
> >&c. -- lots of "thi."s in there.
> >
> >she's trying something equivalent to:
> >
> >  word1=thi.;
> >  word2=this;
> >  sed 's/$word1/$word2/g' file > file.new;
> >
> >and it doesn't replace.
> 
> 
> variable substitution doesn't occur inside single quotes, use double
> quotes instead:
> 
> sed "s/$word1/$word2/g" file

indeed, that was it.

thanks!

</nori>

-- 
    .~.      nori @ sccs.swarthmore.edu
    /V\  http://www.sccs.swarthmore.edu/~nori/jnl/
   // \\          @ maenad.net
  /(   )\       www.maenad.net
   ^`~'^
            get my (*new*) key here:
   http://www.maenad.net/geek/gpg/7ede5499.asc
      (please *remove* old key 11e031f1!)

Attachment: pgpwyBZXJqlNi.pgp
Description: PGP signature


Reply to: