Unanswered: substitution in sed executed in a script
I want to substitute the $1 parameter in a script that executes sed, but I cannot get the substitution to work. I can only get SOOOO close. Here is my script so far:
sed -e 's/foo/$1/g' <infile.nam >outfile.nam
assuming that the above command is in a script called swapme, then typing:
I want every occurance of "foo" in file infile.nam changed to "bar" in file outfile.nam.
What I get is every occurance of "foo" in file infile.nam changed to "$1" in file outfile.nam. The $1 substitution does not "take" and so the literal characters $1 are what gets passed to sed. sed does what it's told to do.
What do I need to do to make the $1 get replaced with "bar"?