Skip to content

Instantly share code, notes, and snippets.

@loopyd
Created July 10, 2019 02:23
Show Gist options
  • Save loopyd/513a14fda32808272b0efafc91586f4f to your computer and use it in GitHub Desktop.
Save loopyd/513a14fda32808272b0efafc91586f4f to your computer and use it in GitHub Desktop.
[ArchTricks] Uninstall last x packages
#!bin/bash
# ArchTricks pacrevert.sh
# By: HeavyPaws "Heavy H. Paws" <loopyd@lupinedream.com>
#
# About:
# This script will remove the last n packages specified by its first argument
#
# Packages are sorted by date. If you ever fuck up and your system won't boot because of a bad group of packages, this
# script is your life preserver.
#
# Dependencies required: expac: pacman -Sy expac
# Shell required: /bin/bash
#
# Usage Example:
#
# pacrevert.sh 50
# Will remove the last 50 installed packages
#
# WARNING: This command ignores dependencies. If you don't know what the hell you're doing, I'd advise not
# using this script at all! Be a good sysadmin and accept responsibility for your own fuckups! :-)
#
local ln
local lx
lx=$1
ln=$(expac -Ql --timefmt=%c '%l\t%n' | sort -n | awk -F ' ' '{print $6}' | tail -n$lx | tr '\n' ' ')
sudo pacman -Rdd $ln
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment