Skip to content

Instantly share code, notes, and snippets.

@k4u5hik
Last active July 27, 2023 05:34
Show Gist options
  • Save k4u5hik/3760173f45ea8c9c5c3fb560800b02d9 to your computer and use it in GitHub Desktop.
Save k4u5hik/3760173f45ea8c9c5c3fb560800b02d9 to your computer and use it in GitHub Desktop.
MacOS system files took up excessive storage. This script deletes files that I believe are safe to be deleted inorder to free up storage.
#!/bin/bash
# Instructions:
# 1) Open Terminal
# 2) Change file permissions "chmod +x macos_cleanup.sh"
# 3) Then run the file "./macos_cleanup.sh"
# Append filepaths to be removed here. Removes reports, backups, archices, cache, etc.
rm -rf ~/Library/Application\ Support/Code/Cache/*
rm -rf ~/Library/Application\ Support/Code/CachedData/*
sudo rm -rfv /private/var/log/asl/*.asl
sudo rm -rfv /Library/Logs/DiagnosticReports/*
sudo rm -rfv /Library/Logs/Adobe/*
rm -rfv ~/Library/Containers/com.apple.mail/Data/Library/Logs/Mail/*
rm -rfv ~/Library/Logs/CoreSimulator/*
sudo rm -rfv /Volumes/*/.Trashes
sudo rm -rfv ~/.Trash
sudo rm -rfv ~/Library/Application\ Support/Adobe/Common/Media\ Cache\ Files/*
rm -rfv ~/Music/iTunes/iTunes\ Media/Mobile\ Applications/*
rm -rfv ~/Library/Application\ Support/MobileSync/Backup/*
rm -rfv ~/Library/Developer/Xcode/DerivedData/*
rm -rfv ~/Library/Developer/Xcode/Archives/*
rm -rfv /Library/Caches/Homebrew/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment