I would like to selected all the installed kernels, including its headers, modules, extras, hwe and architecture, but excluding the current one. So far I have this, but it's not working well:
# Search for all the kernels
CURRENT$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')
PART01="linux-(generic|image|headers|modules|modules-extra)"
PART02="linux-(generic|image|headers|modules|modules-extra)-(hwe|i386|amd64)"
PART03="linux-(image|headers|moduels|modules-extra)-(generic)-(hwe|i386|amd64)"
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $PART01 |grep -E $PART02 |grep -vE $PART03|grep -v $CURRENT)
I'm targeting Ubuntu 18.04 up
-modules
– OldCastle Apr 21 '20 at 05:15sudo apt autoremove
– Sadaharu Wakisaka Apr 21 '20 at 05:24