Skip to content

Instantly share code, notes, and snippets.

@awestendorf
Last active August 23, 2017 13:09
Show Gist options
  • Save awestendorf/2fbe5da79debd344c91c2eebd54c41d4 to your computer and use it in GitHub Desktop.
Save awestendorf/2fbe5da79debd344c91c2eebd54c41d4 to your computer and use it in GitHub Desktop.
Removes old kernels from debian/ubuntu
#!/bin/bash
# Thank you to the person who answered a long-lost post on the internet with this code,
# which I have been using successfully for many years
sudo dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get purge $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment