Home » small fixes » Remove old kernels command (Ubuntu)

Remove old kernels command (Ubuntu)

# dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge

From what I understand the sed command compares the list of the kernels installed with the one used (uname -r) and does not print the name of it. How does it do it … no idea not that good with regex yet.

Posted in small fixes, Useful and tagged as , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.