I used to use this to clean boot.
dpkg -l 'linux-' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]\)./\1/;/[0-9]/!d' | xargs -p sudo apt-get -y purge
Sorry about that, the '*' got removed from a non marked up paste. You are 100% correct. Just a little script to remove all but the current unused kernels that I use on 14.04.
Yep, just take the xargs off to see what it will remove (which would always be good advice when pasting a random script LOL ).
Take off the xargs part of the command and run it to see. :-D
Just looking at it though, it looks like it'll purge kernel packages that are the currently booted one. I don't have a system handy to check though so take that with a grain of salt.