I\'ve successfully used the following sed command to search/replace text in Linux:
sed -i \'s/old_link/new_link/g\' *
However,
Here's how to apply environment variables to template file (no backup need).
echo "Hello {{FOO}}" > foo.conf.tmpl
FOO="world" && sed -e "s/{{FOO}}/$FOO/g" foo.conf.tmpl > foo.conf
Working both macOS 10.12.4 and Ubuntu 14.04.5