Created
August 19, 2019 12:19
-
-
Save knez/396a0d51ae353efa4d4c3f27bc91616e to your computer and use it in GitHub Desktop.
List all user-installed packages (Debian/Ubuntu)
This file contains hidden or 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 | |
| # Lists all user-installed packages | |
| logfile="/var/log/apt/history.log" | |
| logs="zcat $logfile.*.gz | cat - $logfile" | |
| regex="^Commandline: (apt|apt-get) +install +\K( *(\w+-?)+)+" | |
| packages=$(eval $logs | grep -oP "$regex" | tr -s ' ' '\n' | sort -u) | |
| for pkg in $packages; | |
| do | |
| # check if a package is installed | |
| grep-status -PX $pkg &>/dev/null | |
| if [[ $? -eq 0 ]]; then | |
| echo $pkg | |
| fi | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment