“du –max-depth” alternative on Mac OSX

Mattias Geniar, Monday, December 11, 2017 - last modified: Tuesday, December 12, 2017

Ever hard to find obscure places where disk space is wasted on your Mac? If you're accustomed to the Linux terminal, you'll try this:

$ du -h --max-depth=1
du: illegal option -- -
usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m | -g] [-x] [-I mask] [file ...]

... but that doesn't work on Mac.

So here's a Mac alternative:

$ find . -maxdepth 1 -type d -mindepth 1 -exec du -hs {} \;

I try that --max-depth every. single. time.

Update: it's even easier than that

Sure, the find line works, but turns out I've been missing a much easier shortcut here.

$ du -hd1

Lesson learned: blog about it faster! ^^



Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear!. Follow me on Twitter as @mattiasgeniar.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!

Comments

beeb Tuesday, December 12, 2017 at 02:16 - Reply

`du -hd1` works for me.
Followed by adding the largest path that catches my eye, then perhaps the next, and I invariably drill into a log file or some junk folder in Dropbox.


Leave a Reply

Your email address will not be published. Required fields are marked *