<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none"><!--P{margin-top:0;margin-bottom:0;} .ms-cui-menu {background-color:#ffffff;border:1px rgb(171, 171, 171) solid;font-family:'Segoe UI WPC', 'Segoe UI', Tahoma, 'Microsoft Sans Serif', Verdana, sans-serif;font-size:11pt;color:rgb(51, 51, 51);} .ms-cui-menusection-title {display:none;} .ms-cui-ctl {vertical-align:text-top;text-decoration:none;color:rgb(51, 51, 51);} .ms-cui-ctl-on {background-color:rgb(223, 237, 250);opacity: 0.8;} .ms-cui-img-cont-float {display:inline-block;margin-top:2px} .ms-cui-smenu-inner {padding-top:0px;} .ms-owa-paste-option-icon {margin: 2px 4px 0px 4px;vertical-align:sub;padding-bottom: 2px;display:inline-block;} .ms-rtePasteFlyout-option:hover {background-color:rgb(223, 237, 250) !important;opacity:1 !important;} .ms-rtePasteFlyout-option {padding:8px 4px 8px 4px;outline:none;} .ms-cui-menusection {float:left; width:85px;height:24px;overflow:hidden}--></style>
</head>
<body>
<div style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi,<br>
</p>
<p><br>
</p>
<p></p>
<p>Using <span style="font-family: 'courier new', monospace;">sed</span>, <span style="font-family: 'courier new', monospace;">
<span style="font-family: 'courier new', monospace;">uname</span></span> and <span style="font-family: 'courier new', monospace;">
apt</span>, I am trying to ensure that all kernels older than the current and one behind are uninstalled from my machines. I keep the current one, for obvious reasons, and the previous kernel in case I need to roll back.<br>
</p>
<p><br>
</p>
<p>To do this, I'm using <em>`</em><span style="font-family: 'courier new', monospace;"><em>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`</em><span style="font-family: arial, helvetica, sans-serif;"><em>,
</em>which pipes the output of <em style="font-family: 'courier new', monospace;">
<span style="font-family: 'courier new', monospace;">`uname -r `</span></em></span></span><span style="font-family: arial, helvetica, sans-serif;"> to sed, igno</span>res any lines beginning with `ii` to ensure installed kernels aren't removed, and applies
that to the ouput of <span style="font-family: 'courier new', monospace;">`dpkg -l 'linux-*`</span>.<br>
</p>
<p><br>
</p>
<p>This ensures that all previous kernels present are removed.<br>
</p>
<p><br>
</p>
<p>Can I blacklist the previous one, given that I don't know the name, as it may well change?<br>
</p>
<p><br>
</p>
<p>Thanks,<br>
</p>
<p><br>
</p>
<p>Andrew<br>
</p>
<p><br>
</p>
</div>
</body>
</html>