Category filter

Script to Uninstall Apps on Mac

On Mac, users can delete apps by navigating to the ‘Applications’ folder and selecting Move to Trash from the context menu. But this method might leave behind some app files which can take up unwanted space on the system. Run the script below on the Mac Terminal application to remove all associated app files while removing the app from the system.

Device admins can remotely run scripts on Macs managed with Hexnode using the Execute Custom Script action.

Scripting Language – Bash

File extension – .sh

Disclaimer:


The Sample Scripts provided below are adapted from third-party Open-Source sites.

Uninstall an app

Example – sudo rm –rf System/Application/XCode.app

The rm command removes the directory entries on a Mac system. Somes of the options supported with the command in this respect are –

  • -r – Removes the file hierarchy.
  • -f – Removes the files without prompting for confirmation.

We can use this command to remove applications on Mac as applications are also a form of file.

Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository