Clean Up Boot Partition on Ubuntu

I’ve found this little snippet of code very useful in cleaning the /boot partition on Ubuntu:

$dpkg --get-selections | \
  grep 'linux-image*' | \
  awk '{print $1}' | \
  egrep -v "linux-image-$(uname -r)|linux-image-generic" | \
  while read n
  do
    apt-get -y remove $n
  done