Skip to content

Instantly share code, notes, and snippets.

@egg82
Created December 19, 2016 18:15
Show Gist options
  • Save egg82/df2550a0b7cde20153dc51221065d9c1 to your computer and use it in GitHub Desktop.
Save egg82/df2550a0b7cde20153dc51221065d9c1 to your computer and use it in GitHub Desktop.
clean_kernel.sh
#!/bin/bash
currentkernelver=`uname -r | cut -d - -f 1`
echo "Removing old modules.."
for n in /boot/*; do
n2=`echo "$n" | cut -d - -f 2`
if [ $n2 != $currentkernelver ]; then
rm -f $n
fi
done
for n in /usr/lib/debug/lib/modules/*; do
n2=`echo "$n" | rev | cut -d / -f 1 | rev | cut -d - -f 1`
if [ $n2 != $currentkernelver ]; then
rm -rf $n
fi
done
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment