Skip to content

Instantly share code, notes, and snippets.

@apzentral
Created July 11, 2018 15:54
Show Gist options
  • Save apzentral/e29e1fb631049a049653d79d2d10b827 to your computer and use it in GitHub Desktop.
Save apzentral/e29e1fb631049a049653d79d2d10b827 to your computer and use it in GitHub Desktop.
Bash one-liner to delete only old kernels
dpkg -l linux-{image,headers}-* | awk '/^ii/{print $2}' | egrep '[0-9]+\.[0-9]+\.[0-9]+' | grep -v $(uname -r | cut -d- -f-2) | xargs sudo apt-get -y purge