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
Attachment:
pgppYVsLA0peE.pgp
Description: PGP signature