Skip to content

Instantly share code, notes, and snippets.

@heyalexej
Created April 27, 2014 22:08
Show Gist options
  • Save heyalexej/11356827 to your computer and use it in GitHub Desktop.
Save heyalexej/11356827 to your computer and use it in GitHub Desktop.
Log Of All Installed .deb Packages
#!/bin/bash -e
# dpkgdump.sh
# creates text file with a list of all packages installed by date
TMP0=`mktemp "${TMPDIR:-/tmp}"/dpkgdump.col.XXXXXXXXXX`
TMP1=`mktemp "${TMPDIR:-/tmp}"/dpkgdump.res.XXXXXXXXXX`
# next append current log
find /var/log -maxdepth 1 -type f -regex ".*\dpkg\.log\.[0-9].gz$" | xargs zcat > $TMP0
# get unzipped logs
find /var/log -maxdepth 1 -type f -regex ".*\dpkg\.log\.?[0-9]?+$" | xargs cat >> $TMP0
# sort text file by date
cat $TMP0 | sort -n > $TMP1
cat $TMP1
@heyalexej
Copy link
Author

helps examining dpkg log files on foreign systems or when something is messed up etc..

by default the script is writing to stdout after it created the combined and sorted log file. so you can use it with your favorite tools to further examine what's going on.

examples:

./dpkgdump.sh | grep ' installed '
./dpkgdump.sh | grep upgrade | \
                  grep "$2" -A10000000 | \
                  grep "$3" -B10000000 | \
                  awk '{print $4"="$5}'
./dpkgdump.sh | grep ' configure '

further infos:
https://help.ubuntu.com/community/ListInstalledPackagesByDate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment