Skip to content

Instantly share code, notes, and snippets.

@jrnewell
Created October 11, 2014 17:55
Show Gist options
  • Save jrnewell/6f91842358d0c1cb6b83 to your computer and use it in GitHub Desktop.
Save jrnewell/6f91842358d0c1cb6b83 to your computer and use it in GitHub Desktop.
Script to remove old linux kernels from Ubuntu
#!/bin/bash
sudo apt-get autoremove --purge $(dpkg -l 'linux-image-*' | \
sed '/^ii/!d;/'"$(uname -r | \
sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment