Re: [OT] sed expression wildcard bafflement
On Fri, Oct 17, 2003 at 03:56:39PM -0400, 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:
> sed 's/$word1/$word2/g' file > file.new;
Try using double quotes, ie:
sed "s/$word1/$word2/g" file > file.new;
and thank Colin Watson for answering this sort of question
so many times ;-)
> and it doesn't replace.
> i can replicate this from the command line. the only way i can make
> it work is to type out
> sed 's/thi./this/g' file > file.new;
> escaping the period in $word1 does nothing.
> are we just misunderstarding the sed command somehow? otherwise,
> afa[we]k, this is totally weird ...
> .~. nori @ sccs.swarthmore.edu
> /V\ http://www.sccs.swarthmore.edu/~nori/jnl/
> // \\ @ maenad.net
> /( )\ www.maenad.net
> get my (*new*) key here:
> (please *remove* old key 11e031f1!)