Last active
January 31, 2017 08:02
-
-
Save jenrik/6e9978ddf03620d25ddcc88db538ff28 to your computer and use it in GitHub Desktop.
A utility for removing packages on Mac OS X
This file contains 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 | |
# Usage: rm_pkg.sh com.example.app | |
# Find packages names with "pkgutil --pkgs" | |
set -e | |
set -x | |
OLD_PWD=$(pwd) | |
PKG=$1 | |
cd "$(pkgutil --pkg-info $PKG | grep volume | cut -c9-)" | |
cd "$(pkgutil --pkg-info $PKG | grep location | cut -c11-)" | |
pkgutil --only-files --files $PKG | tr '\n' '\0' | tee /dev/tty | xargs -n 1 -0 sudo rm -if | |
pkgutil --only-dirs --files $PKG | tail -r | tr '\n' '\0' | tee /dev/tty | xargs -n 1 -0 sudo rmdir | |
cd $OLD_PWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment