title: scripting insertion of variable to config file
body: <p>As part of a post-preseeding script, I want to disable ipv6.</p>
  
  <p>In <code>/etc/default/grub</code> I want to change this line:</p>
  
  <pre><code>GRUB_CMDLINE_LINX=""
  </code></pre>
  
  <p>so that it reads:</p>
  
  <pre><code>GRUB_CMDLINE_LINUX="ipv6.disable=1"
  </code></pre>
  
  <p>Which can be done with:</p>
  
  <pre><code>sed -i "s/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"ipv6.disable=1\"/" /etc/default/grub
  </code></pre>
  
  <p>But sed won't match if GRUB_CMDLINE_LINUX already has arguments in it.</p>
  
  <p>How can I add the parameter while preserving any existing arguments (if any) ?</p>