Today I found a pop up message on one of my Ubuntu machines that said the boot partition was low on space. I did a search on the web for a cleaning solution for the boot partition and found this page:
I found some flaws in this script so I came with this one trying to improve it:
dpkg -l 'linux-*' | \ # We only need the second column of the installed linux-* packages list awk '/^ii/ { print $2 } ' | \ # Take out the packages with the number of the running kernel grep -v $(uname -r | sed 's/\([0-9.-]\+\)-[^0-9]\+/\1/') | \ # The -v force me into this extra line grep '[0-9]' | \ xargs sudo apt-get -y purge