$ egrep -B2 ^'(Install)':.*linux-image-4.8.0-58 /var/log/apt/history.log
Start-Date: 2017-06-29 22:38:33
Commandline: apt-get dist-upgrade
Install: linux-headers-4.8.0-58:amd64 (4.8.0-58.63~16.04.1, automatic), linux-image-4.8.0-58-generic:amd64 (4.8.0-58.63~16.04.1, automatic),.....
$ sed -n '/Install:.*linux-image-4.8.0-58/p' /var/log/apt/history.log
Install: linux-headers-4.8.0-58:amd64 (4.8.0-58.63~16.04.1, automatic), linux-image-4.8.0-58-generic:amd64 ....
$ sed '/^Install:.*linux-image-4.8.0-58/!{h;d};/^Install:.*linux-image-4.8.0-58/{x;G;}' </var/log/apt/history.log
Commandline: apt-get dist-upgrade
Install: linux-headers-4.8.0-58:amd64 (4.8.0-58.63~16.04.1, automatic), linux-image-4.8.0-58-generic:amd64 ....
sed '/^Start/h;/^Command/H;/^Install/{H;x};/Install/!d' </var/log/apt/history.log
# /^Start/h; speichert den pattern space im hold space, falls das Pattern mit "Start" beginnt.
# /^Command/H fügt den pattern space an den hold space an, falls das Pattern mit "Command" beginnt.
# /^Inst/{H;x}; fügt den pattern space an den hold space an und ersetzt den pattern space durch den holdspace, falls das Pattern mit Install" beginnt.
# /Install/!{d} löscht den pattern space, falls das Pattern nicht "Install" enthält.
sed -n '/^Start-Date:/,/^Install/ p' < /var/log/apt/history.log
sed '/^Start/h;/^Command/H;/^Install/{H;x};/Install/!d' </var/log/apt/history.log
$ sed '/^Start/h;/^Command/H;/^Install.*linux-image-4.10.0-27/{H;x};/Install.*linux-image-4.10.0-27/!d' </var/log/apt/history.log
Start-Date: 2017-07-23 16:39:34
Commandline: apt-get dist-upgrade
Install: linux-headers-4.10.0-27-generic:amd64 (4.10.0-27.30~16.04.2, automatic), linux-image-4.10.0-27-generic:amd64 (4.10.0-27.30~16.04.2, automatic), linux-headers-4.10.0-27:amd64 (4.10.0-27.30~16.04.2, automatic), linux-image-extra-4.10.0-27-generic:amd64 (4.10.0-27.30~16.04.2, automatic)
$ sed '/^Start/h;/^Command/H;/^Purge.*linux-image-4.10.0-27/{H;x};/Purge.*linux-image-4.10.0-27/!d' </var/log/apt/history.log
Start-Date: 2017-09-01 21:44:25
Commandline: apt-get remove --purge --yes linux-headers-4.10.0-27-generic linux-image-4.10.0-27-generic linux-image-extra-4.10.0-27-generic
Purge: linux-headers-4.10.0-27-generic:amd64 (4.10.0-27.30~16.04.2), linux-image-4.10.0-27-generic:amd64 (4.10.0-27.30~16.04.2), linux-image-extra-4.10.0-27-generic:amd64 (4.10.0-27.30~16.04.2)