I am trying to replace a string in a file on a remote server:
ssh $login "
replacement=\`find . -name file\`;
sed -i -e 's/contact/\$replacement/g' path/file;
"
but I can't get the content of the $replacement variable to be used by sed. The example above prints $replacement
in my file. I also tried
sed -i -e 's/contact/\"\$replacement\"/g' path/file;
but it just prints "$replacement"
What would be the correct syntax?
sed
expression, including the variable expansion. This will prevent the shell from expanding your variable. Could you confirm that you want to replace the stringcontact
in some file with the pathnames of a set of files?