1

Situation:

echo "tell me a word"
read the_word

How to replace all WordToReplace in a file by the_word?

sed does not seems to appreciate:

sed -i 's/WordToReplace/$the_word/g' thefile.sh
4

Variables are not expanded within single quotes, they are treated literally then.

Use double quotes instead:

sed -i "s/WordToReplace/$the_word/g" thefile.sh

Not the answer you're looking for? Browse other questions tagged or ask your own question.