title: sed replace entire line at line number with a string that contains nested quotes
body: <p>I want to use <code>sed</code> to replace a certain line with my own string that has to contain some nested quotes because it will be read by another programme and itself executing commands.</p>
  
  <p><code>sed -i '63s/^.*$/mystring/' file.txt</code></p>
  
  <p>Where <code>63</code> is the line number, <code>^.*$</code> is selecting the entire line to replace, <code>mystring</code> is the replacement string and <code>file.txt</code> is the file to work on.</p>
  
  <p>Say for example I want to make <code>mystring</code> <code>exec: echo 'echo "127.0.0.1 localhost" &gt;&gt; /etc/hosts"'</code> how am I supposed to go about that? I've tried escaping the quotes.</p>