Skip to content

Instantly share code, notes, and snippets.

@falkoschumann
Created February 20, 2023 18:13
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 falkoschumann/0b173d08235590353bd82d7146db02c0 to your computer and use it in GitHub Desktop.
Save falkoschumann/0b173d08235590353bd82d7146db02c0 to your computer and use it in GitHub Desktop.
Uninstall macOS pkg
#!/usr/bin/env bash
# list all installed packages
# > pkgutil --pkgs
packageid=$1
set -e
cd /
pkgutil --only-files --files $packageid | tr '\n' '\0' | xargs -n 1 -0 sudo rm -v
pkgutil --only-dirs --files $packageid | tail -r | tr '\n' '\0' | xargs -n 1 -0 sudo rmdir -v
sudo pkgutil --forget $packageid
echo "Successfully uninstalled $packageid"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment