Skip to content

Instantly share code, notes, and snippets.

@alasarr
Last active April 11, 2017 09:44
Show Gist options
  • Save alasarr/9ed3c35a5aaa4264a1fc790e2207dc97 to your computer and use it in GitHub Desktop.
Save alasarr/9ed3c35a5aaa4264a1fc790e2207dc97 to your computer and use it in GitHub Desktop.
Remove old kernels commandline

Remove old kernels

apt-get remove --purge $(dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+' | grep -Fv $(uname -r) |awk '{print $2}')
apt-get remove --purge $(dpkg -l | tail -n +6 | grep -E 'linux-image-extra-[0-9]+' | grep -Fv $(uname -r) |awk '{print $2}')

### Bash script

#!bin/bash
apt-get remove --purge $(dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+' | grep -Fv $(uname -r) |awk '{print $2}')
apt-get remove --purge $(dpkg -l | tail -n +6 | grep -E 'linux-image-extra-[0-9]+' | grep -Fv $(uname -r) |awk '{print $2}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment