title: Adding hugepages to default boot option in grub.conf through bash script
body: <p>I want to add hugepages to grub.conf file through bash script. I can use this command</p>
  
  <pre><code>sed -i '0,/quiet\+/s//\0\ transparent_hugepage=never hugepages=23/' /boot/grub/grub.conf
  </code></pre>
  
  <p>However, this will add to the boot option 0 everytime. I want to check what is the default boot option (default=n) and add it to nth boot option.</p>
  
  <p>Eg: grub.conf</p>
  
  <pre><code>default=1
  title CentOS (3.12.8)
  ...
  kernel ........ quiet
  
  title CentOS (2.6.3)
  ....
  kernel ........ quiet
  </code></pre>
  
  <p>Here I would want to add huge pages for CentOS (2.6.3) after quiet since its the default but </p>
  
  <pre><code>sed -i '0,/quiet\+/s//\0\ transparent_hugepage=never hugepages=23/' /boot/grub/grub.conf 
  </code></pre>
  
  <p>will add it to CentOS (3.12.8)</p>
  
  <p>Any suggestions?</p>
  
  <p>Thank you</p>