I'm writing a bash script that updates my website, but I'm having a problem with sed.
Code:
sed -ri 's:blablabla:muahaahaa:' test.html
works on the command line, but using the same command in the script doesn't update my file. My test script:
Code:
#!/bin/bash
Test_File="test.html"
if [ "$1" -eq 1 ]
then
Search_String="blablabla"
Replace_String="muahaahaa"
else
Search_String="muahaahaa"
Replace_String="blablabla"
fi
sed -ri 's:$Search_String:$Replace_String:' $Test_File
echo "old: ${Search_String}"
echo "new: ${Replace_String}"
exit 0
I've been working on this all afternoon, but haven't found a solution. Any help appreciated!
Edit: I've been posting this a couple of minutes too early, I found the solution. The sed-command in the script must be without single quotes (').