A simple shell script to clean up unnecessary files on macOS — including caches, temp files, logs, and leftovers from deleted applications.
This can help:
- Free up disk space
- Remove old application data
- Keep your Mac feeling fresh
| File Name | Description |
|---|---|
clean_macos.sh |
Main cleanup script that runs all cleaning commands in one go |
README.md |
This documentation |
The script runs a series of safe delete commands targeting common locations for temp files, caches, and app leftovers:
-
Clear User Caches
rm -rf ~/Library/Caches/*
Removes cached files created by apps.
Safe to remove — they’ll be recreated if needed. -
Clear Application Support leftovers
rm -rf ~/Library/Application\ Support/*
Deletes old app data from apps that may no longer be installed.
⚠ If the app is still installed, it will lose its saved data. -
Clear Preferences
rm -rf ~/Library/Preferences/*.plist
Removes preference files (
.plist) from uninstalled apps.
Be careful — this resets settings if the app is still installed. -
Clear Saved Application States
rm -rf ~/Library/Saved\ Application\ State/*
Deletes autosave and restore states for apps.
-
Clear Logs
rm -rf ~/Library/Logs/*
Removes log files — safe to delete.
-
Empty Trash
sudo rm -rf ~/.Trash/*
Empties the Trash folder completely.
git clone https://github.com/<your-username>/<your-repo>.git
cd <your-repo>chmod +x clean_macos.sh./clean_macos.shYou may be prompted for your password (needed for emptying Trash).
If you don’t want to delete certain files (e.g., Application Support),
simply comment out the line by adding a # at the start:
# rm -rf ~/Library/Application\ Support/*- This script permanently deletes files — they are not recoverable once removed.
- Make sure to review the commands before running.
- If you’re unsure about deleting something, comment it out first.
🧹 Starting macOS cleanup...
Deleting user caches...
Deleting Application Support leftovers...
Deleting Preferences...
Deleting saved app states...
Deleting logs...
Emptying Trash...
✅ macOS cleanup complete!
This project is released under the MIT License — feel free to modify and share.