Last active
August 29, 2015 14:13
-
-
Save CpuID/f0ae6c3cafe3e344c11e to your computer and use it in GitHub Desktop.
Get first kernel version to be booted from Grub Config (menu.lst) - Ubuntu Kernels
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
#!/usr/bin/env bash | |
grub_config="/boot/grub/menu.lst" | |
if [ ! -f "${grub_config}" ]; then | |
echo "Grub config ${grub_config} not found." | |
exit 1 | |
fi | |
boot_default=$(grep ^default "${grub_config}" | awk '{print $2}') | |
let boot_default_plus_1=$boot_default+1 | |
version=$(grep ^kernel "${grub_config}" | sed -n "${boot_default_plus_1}p" | awk '{print $2}' | sed 's/\/boot\/vmlinuz-//') | |
echo "${version}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment