Last active
February 2, 2017 13:30
-
-
Save jklmnn/d4e84a10442e5ff8b9e589499d2aeeed to your computer and use it in GitHub Desktop.
Removes all kernels installed under Debian/Ubuntu that aren't loaded.
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/bash | |
kernels=$(dpkg -l | grep -E "ii linux-(image|headers)-[0-9]\.[0-9]\.[0-9]-.*" | grep -v $(uname -r | cut -d"-" -f1,2) | cut -d" " -f3) | |
echo "Current kernel: $(uname -r)" | |
echo "Remove kernels:" | |
echo "$kernels" | |
read -p "Execute? (y/n)" choice | |
if [ "$choice" == "y" ] | |
then | |
echo $kernels | xargs sudo apt-get remove -y | |
else | |
echo "Abort." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment