title: Add a kernel parameter with sed to grub
body: <p>I'm writing a bash script to non-interactively enable hibernation on a linux system. To this end, I need to insert a shell variable that contains slashes on a specific line of a while, inside quotes that are on that line.</p>
  
  <p>The relevant part of the file to b edited looks like this:</p>
  
  <pre><code>GRUB_DEFAULT=0
  GRUB_TIMEOUT=5
  GRUB_DISTRIBUTOR="Manjaro"
  GRUB_CMDLINE_LINUX_DEFAULT="quiet"
  GRUB_CMDLINE_LINUX=""
  </code></pre>
  
  <p>I need to change it to this:</p>
  
  <pre><code>GRUB_DEFAULT=0
  GRUB_TIMEOUT=5
  GRUB_DISTRIBUTOR="Manjaro"
  GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=/dev/disk/by-partuuid/c5a552c2-fe8f-423a-9037-c35bf090d9c3"
  GRUB_CMDLINE_LINUX=""
  </code></pre>
  
  <p>The added parameter is provided by a shell variable.</p>
  
  <p>I tried this:</p>
  
  <pre><code>sed -i '\*^GRUB_CMDLINE_LINUX_DEFAULT* s*"$* '"$(grub_resume_boot_option)"'"*' /etc/default/grub
  </code></pre>
  
  <p>Logic that I was aiming for was: "Look for a line that starts with pattern "GRUB_CMDLINE_LINUX_DEFAULT", and replace the last " with the given pattern. Use * as delimiter to preserve the slashes in the expanded variable."</p>
  
  <p>However, the command fails if there are any spaces at the end of the line. Is there any way to make it not take spaces at the end of the line into account?</p>
  
  <p>Also, if there is more simple or readable solution to this, I would be very interested.</p>