Created
November 22, 2019 16:37
-
-
Save isaaclw/a9d0bb9f2510737c30af4196245bb8da to your computer and use it in GitHub Desktop.
Reboot Grup to the specific OS you specify #grub #bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if ! grep "GRUB_DEFAULT=saved" /etc/default/grub > /dev/null; then | |
sudo sed -i 's/^GRUB_DEFAULT=.*/GRUB_DEFAULT=saved/' /etc/default/grub | |
fi | |
echo | |
echo "== SELECT WHICH OS TO BOOT ==" | |
echo | |
sudo cat /boot/grub/grub.cfg | grep -oE "^menuentry '[^']+'" | awk -F\" '{print N++,$(NF-1)}' | |
echo | |
read -p "Enter number (q to abort) and press ENTER: " CHOICE | |
if [ "$CHOICE" != "q" ] ; then | |
sudo grub-reboot $CHOICE | |
sudo shutdown -r now | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment