Skip to content
Advertisement

How to search /var/log/dpkg.log for monthly install/upgrade logs and output to text file

I would like to output a file with install/upgrade logs limited to the past month by looking in /var/log/dpkg.log.

I do not know bash, I know that the grep command could make it, but I still need some help.

Advertisement

Answer

$ grep "install|upgrade" /var/log/dpkg.log | grep "2021-01" > log.dat

Sample output:

2021-01-11 23:05:50 status installed mime-support:all 3.62
2021-01-11 23:05:50 status installed hicolor-icon-theme:all 0.17-2
2021-01-11 23:05:53 status installed shared-mime-info:amd64 1.10-1
2021-01-12 11:11:57 install python3-configobj:all <none> 5.0.6-3
2021-01-12 11:11:57 status half-installed python3-configobj:all 5.0.6-3
2021-01-12 11:11:57 install python3-psutil:amd64 <none> 5.5.1-1
2021-01-12 11:11:57 status half-installed python3-psutil:amd64 5.5.1-1
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement