“du –max-depth” alternative on Mac OSX

Oh Dear! monitors your entire site, not just the homepage. We crawl and search for broken pages and mixed content, send alerts when your site is down and notify you on expiring SSL certificates.

Start your free 10 day trial! »

Image of Mattias Geniar

Mattias Geniar, December 11, 2017

Follow me on Twitter as @mattiasgeniar

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! ^^

Will you help me share this post?

It would mean a lot to me if you could help share this post on social media. 🤗