Created
February 18, 2013 23:04
-
-
Save anderseknert/4981582 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
logdir="/var/log/" | |
installed="" | |
# Scan all dpkg logs for installed packages | |
for file in ${logdir}dpkg.log*; do | |
if [ ${file##*.} = "gz" ]; then | |
installed=$installed`gzip -dc $file | grep ' installed' | cut -d' ' -f5` | |
else | |
installed=$installed`cat $file | grep ' installed' | cut -d' ' -f5` | |
fi | |
done | |
# Get all packages installed at the time of OS installation | |
os_installed=`gzip -dc ${logdir}installer/initial-status.gz | grep 'Package: ' | cut -d' ' -f2` | |
# Get all automatically installed packages | |
auto_installed=`apt-mark showauto` | |
# Concatenate all the installed packages.. | |
all_installed="${installed}${os_installed}${auto_installed}" | |
# ..and remove all duplicates, which leaves only user installed packages | |
echo "${all_installed}" | sort | uniq -u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment