0

What I want to script is something along the lines of:

if [ uname -r is not == highest version of kernel RPM installed ]
then
  echo "You need to reboot to use the latest kernel"
fi

The problem is, if the output of

rpm -q kernel
is something like:

kernel-2.6.32-358.10.2.el6.x86_64
kernel-2.6.32-358.6.1.el6.x86_64

… how do I determine which is higher? I know a simple string sort is not reliable (it will be backwards with this example). Is there a shortcut with rpm or do I have to parse out everything and compare it myself?