shell script to alter grub menu.lst

Hi folks,

I have a dual-boot Ubuntu/Windows machine and I wanted to create a script to change the menu.lst file so it will change the default boot partition (this is so I can reload the machine remotely and allow it to boot to the Windows partition).

Today I have to sudo cp a template file I created changing the default boot, but wanted to have something simpler.

Also I wanted to change only the default line of the actual menu.lst instead of relying on a template so if there are any changes to the running menu.lst I do not overwrite them.

Any thoughts?

---------- Post updated at 04:02 PM ---------- Previous update was at 04:00 PM ----------

for simplicity's sake...

I want to look into the menu.lst file for a line containing:

default 3

and change it to:

default 0

considering that menu.lst is a protected file and you need root to change it...

This is an example of what you need:

sudo "sed -e 's/default 3/default 0/' /boot/grub/menu.lst > /tmp/menu.lst.$$ && cp /tmp/menu.lst.$$ /boot/grub/menu.lst"