Skip to content

Instantly share code, notes, and snippets.

@jacksonporter
Last active November 18, 2023 18:39
Show Gist options
  • Save jacksonporter/4a972e8c6039a19f5dff7bf1cc3c0303 to your computer and use it in GitHub Desktop.
Save jacksonporter/4a972e8c6039a19f5dff7bf1cc3c0303 to your computer and use it in GitHub Desktop.
Remove Office from macOS
#!/usr/bin/env bash
set -e
LIB_CONTAINERS_DIR="${HOME}/Library/Containers"
SUB_LIB_CONTAINERS=("Microsoft Error Reporting" "Microsoft Excel" "com.microsoft.netlib.shipassertprocess" "com.microsoft.Office365ServiceV2" "Microsoft Outlook" "Microsoft PowerPoint" "com.microsoft.RMS-XPCService" "Microsoft Word" " Microsoft OneNote")
LIB_GROUP_CONTAINERS_DIR="${HOME}/Library/Group Containers"
SUB_LIB_GROUP_CONTAINERS=("UBF8T346G9.ms" "UBF8T346G9.Office" "UBF8T346G9.OfficeOsfWebHost")
function main() {
local current_dir
echo "Going to try to removing Office Apps (your password may be required)" 1>&2
sudo rm -rf /Applications/Microsoft* /Applications/Onedrive*
sudo rm -rf "${HOME}"/Applications/Microsoft* "${HOME}"/Applications/Onedrive*
echo "Going to try to removing Office Configuration Files (your password may be required)" 1>&2
for ((i = 0; i < ${#SUB_LIB_CONTAINERS[@]}; i++))
do
current_dir="${LIB_CONTAINERS_DIR}/${SUB_LIB_CONTAINERS[$i]}"
echo "Trying to remove: ${current_dir}"
sudo rm -rf "${current_dir}"
done
for ((i = 0; i < ${#SUB_LIB_GROUP_CONTAINERS[@]}; i++))
do
current_dir="${LIB_GROUP_CONTAINERS_DIR}/${SUB_LIB_GROUP_CONTAINERS[$i]}"
echo "Trying to remove: ${current_dir}"
sudo rm -rf "${current_dir}"
done
}
# shellcheck disable=SC2068
main ${@}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment