Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/bin/sh
#
# pacman-ls.sh: List installed packages by repo.
#
# Copyright 2010 Tom Vincent <http://www.tlvince.com/contact/>
PACKAGES="$(pacman -Sl)"
REPOS="$(echo "$PACKAGES" | cut -f1 -d ' ' | uniq)"
OUT="$HOME/bak/packages/tmp"
VERBOSE=true
mkdir -p "$OUT"
$VERBOSE && echo "Total installed packages:"
for repo in $REPOS; do
list="$(echo "$PACKAGES" | grep "^$repo")"
installed="$(echo "$list" | grep "\[installed\]")"
echo "$installed" | cut -f2 -d ' ' > "$OUT/$repo-$(date +"%F").txt"
$VERBOSE && {
echo "$repo: $(echo "$installed" | wc -l)/$(echo "$list" | wc -l)"
}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment