Last active
September 9, 2015 20:53
-
-
Save glarrain/e1e71fc8aa9139b7afe0 to your computer and use it in GitHub Desktop.
Write list of manually installed packaged (and when) in a Ubuntu system by looking in dpkg logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# source: https://help.ubuntu.com/community/ListInstalledPackagesByDate | |
#creates text file with a list of all packages installed by date | |
#first append all info from archived logs | |
i=2 | |
mycount=$(ls -l /var/log/dpkg.log.*.gz | wc -l) | |
nlogs=$(( $mycount + 1 )) | |
while [ $i -le $nlogs ] | |
do | |
if [ -e /var/log/dpkg.log.$i.gz ]; then | |
zcat /var/log/dpkg.log.$i.gz | grep "\ install\ " >> $HOME/pkgtmp.txt | |
fi | |
i=$(( $i+1 )) | |
done | |
#next append all info from unarchived logs | |
i=1 | |
nulogs=$(ls -l /var/log/dpkg.log.* | wc -l) | |
nulogs=$(( $nulogs - $nlogs + 1 )) | |
while [ $i -le $nulogs ] | |
do | |
if [ -e /var/log/dpkg.log.$i ]; then | |
cat /var/log/dpkg.log.$i | grep "\ install\ " >> $HOME/pkgtmp.txt | |
fi | |
i=$(( $i+1 )) | |
done | |
#next append current log | |
cat /var/log/dpkg.log | grep "\ install\ " >> $HOME/pkgtmp.txt | |
#sort text file by date | |
sort -n $HOME/pkgtmp.txt > $HOME/pkginstalls.txt | |
rm $HOME/pkgtmp.txt | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To just obtain a list of the packages installed at the moment (even those included by default in the OS) run