From the Debian/Ubuntu grub configuration file /boot/grub/grub.cfg, I would like to extract only the Linux Kernel Version columns, using AWK.
I wrote one but very long command using pipes. Can we make it short?.
My command:
# awk -F"--class" '/menuentry/ && /with Linux/ {print $1}' /boot/grub/grub.cfg | awk '{print i++ " : " $5,$6,$7,$8}' | sed -e "s/'/ /g"
0 : Linux 5.12.1
1 : Linux 5.12.1 (recovery mode)
2 : Linux 4.19.0-14-amd64
3 : Linux 4.19.0-14-amd64 (recovery mode)
The above output is the desired output I wanted but I would like to know if the command can be shorter to produce the same output?.