Remove all kernel except 2.6.18-308.24.1.el5

Hello All,

I would like to remove all kernel in the system except 2.6.18-308.24.1.el5.
I was trying something like

rpm -qa|grep kernel|grep -v 2.6.18-308.24.1.el5|yum remove

it did not work. any help?

Thanks

What's your system?

I rather would advise to be very careful with system maintenance like this. As this very likely is a one off task, why not do it manually and check every step? List the kernels with rpm -qa , can't be that many, and select each single one to remove by hand.