title: How to escape $ in sed over ssh command?
body: <p>I am trying to create a patch that users can use to remotely edit a file in a pre-defined way using sed, and I could do this manually on each computer, but it would take a long time.</p>
  
  <p>The line I am struggling with is as follows:</p>
  
  <pre><code>host=[hostname]
  port=[portnum]
  ssh -t $host -p $port "cp ~/file1 ~/file1.bak ; sed -i \"s/fcn1('param1', $2)\n/fcn2('param2'):$zoom\n/g\" ~/file1"
  </code></pre>
  
  <p>This makes a backup of file1 and then edits a line in the file.  I actually want to edit more than one line, but this line demonstrates the problems:
  The command works, provided no $ signs are used within the sed command.</p>
  
  <p>I have tried a number of ways of escaping these $ signs but cannot seem to find one that works.
  I can use a . wildcard in the find, but obviously not in the replace string.</p>
  
  <p>I would use single quotes for the sed command, in order to avoid expanding the $2, but single quotes are already used inside the command.</p>
  
  <p>Does anyone have any ideas of how to overcome this problem?  Thanks in advance for any suggestions!</p>