<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dadu14-code</title>
    <description>The latest articles on DEV Community by dadu14-code (@dadu14code).</description>
    <link>https://dev.to/dadu14code</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3914873%2Ffc824252-0869-4bf7-a1c6-1d01cf9bb1ac.png</url>
      <title>DEV Community: dadu14-code</title>
      <link>https://dev.to/dadu14code</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dadu14code"/>
    <language>en</language>
    <item>
      <title>I freed 80GB on my Mac with a bash script — no app, no subscription</title>
      <dc:creator>dadu14-code</dc:creator>
      <pubDate>Wed, 06 May 2026 00:23:37 +0000</pubDate>
      <link>https://dev.to/dadu14code/i-freed-80gb-on-my-mac-with-a-bash-script-no-app-no-subscription-3deg</link>
      <guid>https://dev.to/dadu14code/i-freed-80gb-on-my-mac-with-a-bash-script-no-app-no-subscription-3deg</guid>
      <description>&lt;p&gt;My Mac mini was telling me I had &lt;strong&gt;over 80GB of "System Data"&lt;/strong&gt; to free up. CleanMyMac wanted €34/year. DaisyDisk wanted €10 just to tell me where the files were.&lt;/p&gt;

&lt;p&gt;So I spent an evening writing a bash script instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with "System Data" on macOS
&lt;/h2&gt;

&lt;p&gt;If you've ever opened &lt;strong&gt;System Settings → General → Storage&lt;/strong&gt; and seen a huge "System Data" slice, you know the feeling. macOS is notoriously vague about what's in there.&lt;/p&gt;

&lt;p&gt;The real culprits are usually:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Time Machine local snapshots&lt;/strong&gt; — macOS keeps these silently on your SSD, often tens of GB&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Xcode DerivedData and archives&lt;/strong&gt; — rebuilds from old projects you haven't touched in months&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Game data&lt;/strong&gt; from titles you uninstalled ages ago&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;iMazing or other backup apps&lt;/strong&gt; storing full iPhone backups locally&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App caches&lt;/strong&gt; that grow indefinitely and are never cleaned automatically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these show up clearly in Finder. You need to know where to look.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: find out where your space went
&lt;/h2&gt;

&lt;p&gt;Before deleting anything, I built a diagnostic tool that uses &lt;strong&gt;Spotlight&lt;/strong&gt; (&lt;code&gt;mdfind&lt;/code&gt;) to instantly find files over 500 MB — no slow full-disk scan, results in seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash mac-find-space.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On my Mac it found, among other things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;25 GB Windows 11 virtual machine&lt;/strong&gt; I hadn't booted in months&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;22 GB of iMazing backups&lt;/strong&gt; duplicating what was already on iCloud&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;6.5 GB of Magic: The Gathering Arena&lt;/strong&gt; downloads from a game I quit playing&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;4.9 GB of macOS aerial wallpaper cache&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Several GB of &lt;strong&gt;Time Machine local snapshots&lt;/strong&gt; that macOS never told me about&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Total: over 80 GB of recoverable space, none of it visible at a glance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: clean it safely
&lt;/h2&gt;

&lt;p&gt;The main script — &lt;code&gt;macos-cleanup.sh&lt;/code&gt; — runs in &lt;strong&gt;dry-run mode by default&lt;/strong&gt;. It shows you everything it would delete without touching a single file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Preview (safe, nothing is deleted)&lt;/span&gt;
bash macos-cleanup.sh

&lt;span class="c"&gt;# Clean interactively&lt;/span&gt;
bash macos-cleanup.sh &lt;span class="nt"&gt;--clean&lt;/span&gt;

&lt;span class="c"&gt;# Clean everything automatically&lt;/span&gt;
bash macos-cleanup.sh &lt;span class="nt"&gt;--clean&lt;/span&gt; &lt;span class="nt"&gt;--yes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what a dry-run looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;══════════════════════════════════════════════════════════
  🍎  macOS Cleanup Utility
══════════════════════════════════════════════════════════
  MODE: DRY-RUN — nothing will be deleted
  Disk free before: 4.8 GB
══════════════════════════════════════════════════════════

[1] User caches  ~/Library/Caches
  [DRY-RUN]  ~/Library/Caches                              2.1 GB

[2] Logs
  [DRY-RUN]  ~/Library/Logs                               1.6 GB
  [DRY-RUN]  /Library/Logs                               23 MB
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What it cleans
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Section&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;User &amp;amp; system caches&lt;/td&gt;
&lt;td&gt;Regenerated automatically&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logs&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;/Library/Logs&lt;/code&gt;, &lt;code&gt;/private/var/log&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Temp files&lt;/td&gt;
&lt;td&gt;Cleared on reboot anyway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trash&lt;/td&gt;
&lt;td&gt;All volumes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Xcode DerivedData, Archives, Simulators&lt;/td&gt;
&lt;td&gt;Only if Xcode is installed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Time Machine local snapshots&lt;/td&gt;
&lt;td&gt;via &lt;code&gt;tmutil&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Homebrew / npm / pip cache&lt;/td&gt;
&lt;td&gt;Only if installed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Webex upgrade packages&lt;/td&gt;
&lt;td&gt;Old installer leftovers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Game data &lt;em&gt;(optional, interactive)&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;MTG Arena, Pokémon TCG, Steam, Epic...&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;iMazing backups &lt;em&gt;(optional)&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;Only if you have backups elsewhere&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Aerial wallpapers &lt;em&gt;(optional)&lt;/em&gt;
&lt;/td&gt;
&lt;td&gt;macOS re-downloads them if needed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What it never touches
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;iCloud Drive and OneDrive synced files&lt;/li&gt;
&lt;li&gt;iOS backups (shows size info only — remove via Finder)&lt;/li&gt;
&lt;li&gt;macOS system files&lt;/li&gt;
&lt;li&gt;Your documents, photos, downloads&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why not just use CleanMyMac?
&lt;/h2&gt;

&lt;p&gt;Nothing wrong with it — it's a polished app. But:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It costs money every year&lt;/li&gt;
&lt;li&gt;It runs in the background&lt;/li&gt;
&lt;li&gt;You can't read its source code&lt;/li&gt;
&lt;li&gt;It has more features than most people need&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This script is ~200 lines of readable bash. You can open it, read every line, and know exactly what it does before running it. No black box.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/dadu14-code/mac-janitor.git
&lt;span class="nb"&gt;cd &lt;/span&gt;mac-janitor
bash mac-find-space.sh      &lt;span class="c"&gt;# find out where your GBs went&lt;/span&gt;
bash macos-cleanup.sh       &lt;span class="c"&gt;# preview what would be cleaned&lt;/span&gt;
bash macos-cleanup.sh &lt;span class="nt"&gt;--clean&lt;/span&gt;  &lt;span class="c"&gt;# clean when ready&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/dadu14-code/mac-janitor" rel="noopener noreferrer"&gt;dadu14-code/mac-janitor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tested on macOS Ventura, Sonoma and Sequoia. Pure bash, no dependencies, MIT license.&lt;/p&gt;




&lt;p&gt;Feedback welcome — especially if you find new paths worth cleaning or test it on older macOS versions. PRs are open.&lt;/p&gt;

</description>
      <category>macos</category>
      <category>bash</category>
      <category>opensource</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
