Skip to content

Instantly share code, notes, and snippets.

@anorm
Created March 4, 2018 10:16
Show Gist options
  • Save anorm/eb5de59463bf7c6e54d65fbd42c2443c to your computer and use it in GitHub Desktop.
Save anorm/eb5de59463bf7c6e54d65fbd42c2443c to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# From https://askubuntu.com/questions/401581/bash-one-liner-to-delete-only-old-kernels
dpkg -l linux-{image,headers}-* | awk '/^ii/{print $2}' | egrep '[0-9]+\.[0-9]+\.[0-9]+' | grep -v $(uname -r | cut -d- -f-2) | xargs sudo apt-get -y purge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment