Skip to content

Instantly share code, notes, and snippets.

@jenrik
Last active January 31, 2017 08:02
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 jenrik/6e9978ddf03620d25ddcc88db538ff28 to your computer and use it in GitHub Desktop.
Save jenrik/6e9978ddf03620d25ddcc88db538ff28 to your computer and use it in GitHub Desktop.
A utility for removing packages on Mac OS X
#!/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