Created
October 18, 2017 13:42
-
-
Save RushOnline/2dcc1a8bdf2d005a030d6b093af77db8 to your computer and use it in GitHub Desktop.
Remove old Ubuntu kernels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
FRESH_KERNEL=$(ls -1 /boot/vmlinuz-*-generic | tail -n1 | egrep -o '[0-9]+.*') | |
dpkg -l linux-{image,headers}-* | awk '/^ii/{print $2}' | egrep '[0-9]+\.[0-9]+\.[0-9]+' | grep -v $(uname -r | cut -d- -f-2) | grep -v $FRESH_KERNEL | xargs apt -y purge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment