I am looking for a way to remove all the old kernels but keep 1 just in case.
dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p' | xargs sudo apt-get -y purge
This command has worked fairly well but removes all old kernels. Is it possible to leave a spare kernel?