Skip to content

Instantly share code, notes, and snippets.

@sarum9in
Last active August 29, 2015 14:14
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 sarum9in/ad8c4b77a94db0413683 to your computer and use it in GitHub Desktop.
Save sarum9in/ad8c4b77a94db0413683 to your computer and use it in GitHub Desktop.
revert_last
#!/bin/bash -e
regex='^(\[.*\]) (\[.*\]) ([^ ]+) ([^ ]+) \((.*) -> (.*)\)$'
prepare()
{
while read str
do
date=$(echo $str | sed -r "s|$regex|\1|")
db=$(echo $str | sed -r "s|$regex|\2|")
action=$(echo $str | sed -r "s|$regex|\3|")
pkg=$(echo $str | sed -r "s|$regex|\4|")
v1=$(echo $str | sed -r "s|$regex|\5|")
v2=$(echo $str | sed -r "s|$regex|\6|")
ls /var/cache/pacman/pkg/${pkg}-${v1}*.pkg.tar.xz
done
}
pacman -U "$(grep $1 /var/log/pacman.log | grep upgraded | prepare)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment