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

Re: [OT] sed expression wildcard bafflement

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;

and it doesn't replace.

variable substitution doesn't occur inside single quotes, use double quotes instead:

sed "s/$word1/$word2/g" file

Attachment: pgp3pctWpoB2V.pgp
Description: PGP signature

Reply to: