Last active
March 30, 2019 22:37
-
-
Save olivertappin/1628438fbb9460743a9021cddd7221ce to your computer and use it in GitHub Desktop.
Remove unused headers on Ubuntu
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 | |
| # Run the following command to run this script locally: | |
| # sh -c "$(curl -sSL https://gist.github.com/olivertappin/1628438fbb9460743a9021cddd7221ce/raw)" | |
| headers=$(dpkg --list | grep -E 'linux-image-[0-9]+\.[0-9]+\.[0-9]+-[0-9]+[0-9]+-generic' | awk {'print $2'} | grep -v `uname -r`) | |
| echo "Current header: " | |
| uname -r | |
| echo "" | |
| echo "Found the following unused headers:" | |
| for header in $headers | |
| do | |
| echo $header; | |
| done | |
| echo "" | |
| echo "This program will remove the unused headers listed above." | |
| read -p "Do you want to continue? [Y/n]" REPLY | |
| echo "" | |
| if [ "$REPLY" = "y" ] || [ "$REPLY" = "Y" ] | |
| then | |
| for header in $headers | |
| do | |
| sudo apt-get purge -y $header | |
| done | |
| echo "Complete. Consider running `sudo apt autoremove` to remove unused headers from disk." | |
| else | |
| echo "Not sure why you asked in the first place then... bye."; | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment