Category filter
Script to uninstall apps on Mac
On Macs, users typically delete apps by navigating to the Applications folder and selecting Move to Trash from the app’s context menu. The primary motive for uninstalling apps is often to free up storage space. However, this manual method may leave behind residual app files, occupying unwanted space on the system.
In organizational settings, managing apps across multiple devices can be a challenge. For instance, if a malicious app is discovered on several devices, IT admins must uninstall it simultaneously from all affected devices. Similarly, after an app’s testing phase, if it needs to be removed, IT admins would have to uninstall it from each device.
In such cases, they can utilize Hexnode’s Execute Custom Script action to run the script given below to uninstall the required apps from macOS devices.
Scripting language – Bash
File extension – .sh
Uninstall an app
1 2 |
#!/bin/bash sudo rm -rf /path to the app files |
Example – sudo rm –rf /Applications/Opera.app
The rm
command removes the directory entries on a Mac. Some of the options supported with the command in this respect are –
-r
: Removes the file hierarchy.
-f
: Removes the files without prompting for confirmation.
This command can be used to remove applications on Mac as applications are also a form of file.
What happens at the device end?
The script uninstalls the application on the macOS device without any manual intervention. In addition, it clears the cache files associated with the application.