Skip to content

Instantly share code, notes, and snippets.

@vinitkumar
Last active August 29, 2015 14:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinitkumar/e97a82970caabb51a204 to your computer and use it in GitHub Desktop.
Save vinitkumar/e97a82970caabb51a204 to your computer and use it in GitHub Desktop.

Small Guide To Clean Your Mac

Sometimes, your mac is filled up with files and you can't seem to understand what really is taking much space. Here is how you can find out.

  • First of all find disk usage and save it to a log file. Also, find all big files that are there. Grepping using 'G' would find all files that are in GB.

Also, save the second list to another file so that we are only doing it once.

du -h > ~/space.log
cat ~/space.log | awk '{print $1}' | grep 'G' >  ~/highspace.log

Next, open a split window and do

cat ~/highspace.log

And Now, start finding the ones which are big one by one.

Let's say one of the entry was 5.6G, Let's find which one was it.

du -h | grep '5.6G'
#which outputs
5.6 ./Document/Movie.avi

Now, if you feel the file is not needed and you want to delete it. Do the following:

sudo rm -rf Documents/Movie.avi

Voila! Repeat this process and remove all files and directories that you no longer need.

Disclaimer:

Do it very patiently and backup everything that's important. This guide is for very advanced users and you should only do it if you know what you are doing. I am responsible for any data loss. Do it at your own risk.

@christiangenco
Copy link

This is neat! For a similar solution, I use Grand Perspective or Disk Inventory X, though the paid Daisy Disk is much prettier.

@vinitkumar
Copy link
Author

@christiangenco: Thanks. :) Yes, I saw some of these but felt writing a small bash script is easier and faster way to achieving this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment