Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
echo "tell me a 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
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