Skip to content

Instantly share code, notes, and snippets.

@wastrachan
Created July 6, 2019 05:33
Show Gist options
  • Save wastrachan/24d672895397f86f7092bb69d15dca99 to your computer and use it in GitHub Desktop.
Save wastrachan/24d672895397f86f7092bb69d15dca99 to your computer and use it in GitHub Desktop.
#! /bin/bash
#
# APT Installed
# Compare currently installed packages with archived package list
#
# (c) Winston Astrachan 2019
ARCHIVE_FILE=/etc/apt/basepackages.txt
if [ ! -f "$ARCHIVE_FILE" ]; then
read -r -p "Base package list does not exist at $ARCHIVE_FILE. Create it now? [Y/n]" response
if [[ $response =~ ^(yes|y|Y| ) ]] || [[ -z $response ]]; then
dpkg -l | awk 'NR > 3 { print }' | awk '{ print $2 }' | sort > $ARCHIVE_FILE
else
echo "Aborting..."
exit 0
fi
fi
dpkg -l | awk 'NR > 3 { print }' | awk '{ print $2 }' | sort | diff -y - $ARCHIVE_FILE | less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment