I set up a variable in the shell:
-bash-3.00$ echo $source_repl
source ../setup_simple.tcl
I then tried to replace a line in a file that started with the string "package require IxLoad" with the variable string (noting that double quotes are the way to get sed to use variable substitution). First I tried with direct substitution (no escaping the $ in the variable):
-bash-3.00$ sed -e "s/package require IxLoad.*/$source_repl/g" smtp_tput191Mb.tcl > tmpwatch.tcl
sed: -e expression #1, char 38: unknown option to `s'
-bash-3.00$
So I thought that escaping the $ would solve the problem but as you can see the line is then replaces by the literal string "$source_repl" rather than the variable stored there:
-bash-3.00$ sed -e "s/package require IxLoad.*/\$source_repl/g" smtp_tput191Mb.tcl > tmpwatch.tcl
-bash-3.00$ diff smtp_tput191Mb.tcl tmpwatch.tcl
11c11
< package require IxLoad
---
> $source_repl
-bash-3.00$
I looked up many sites on how to do variable substitution in sed and they all seem to indicate that the above should work. What am I missing? Is there something in the actual variable that's causing this?
A