DEV Community

Cover image for Clean Up Your Mac From Other Files
Vinit Kumar
Vinit Kumar

Posted on

Clean Up Your Mac From Other Files

screenshot

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.

 cat ~/space.log | fgrep -f highspace.log

 #It will give something like this:

1.2G    ./.android/avd/Nexus_6_API_21.avd
2.7G    ./.android/avd
2.7G    ./.android

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 not responsible for any data loss. Do it at your own risk.

Top comments (4)

Collapse
 
chiborg profile image
Gabriel Birke

Thank you for this gentle introduction, I hope more people will get comfortable with the shell.

But for cleanup tasks, I prefer to use the fantastic GUI utility called DaisyDisk (daisydiskapp.com).

If you want a free option you could use Disk Inventory X (derlien.com)

Collapse
 
brainmaestro profile image
Ezinwa Okpoechi

To make this even simpler, you can do du -h | awk '$1 ~ /[0-9]G/'. No separate files created, and much shorter and easier to understand.

Collapse
 
vinitkumar profile image
Vinit Kumar

Thanks. Much nicer.

Collapse
 
ningtrendmicro profile image
Ivan

this blog would solve your question drcleaner.com/mac-hard-disk-free/