- using
pkgutil
# list all your installed packages
pkgutil --pkgs
# show your package info
pkgutil --pkg-info <your-package-id>
# list your package files
pkgutil --files <your-package-id>
# change to the directory which your package is installed into
cd /
# remote files
pkgutil --only-files --files <your-package-id> | tr '\n' '\0' | xargs -n 1 -0 sudo rm -if
# remote directories
pkgutil --only-dirs --files <your-package-id> | tail -r | tr '\n' '\0' | xargs -n 1 -0 sudo rmdir
How does
rm -if
make sense? This rm man page says that-i
means "prompt before every removal", but-f
means "never prompt"! Moreover, prompting is useless since stdin is coming from a/dev/null
thanks toxargs
. Right?Note also that
pkgutil --files
can output names of important directories shared with other programs, e.g.usr
. That's OK if you usermdir
as this script does, because it won't remove empty directories. But if you modify the commands, e.g. to userm -r
, be very careful.