Skip to content

Instantly share code, notes, and snippets.

@tlvince
Created October 6, 2010 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlvince/613109 to your computer and use it in GitHub Desktop.
Save tlvince/613109 to your computer and use it in GitHub Desktop.
#!/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