Disk usage in Mac terminal not working with --max-depth
I want to see my disk usage for a specific folder with a pre-set maximum depth. On Linux, the command is
$ du -h --max-depth 1
On macOS Mojave (10.14.5) with bash version 3.2.57(1)-release
, this is not working. I also tried
$ du -hd1
as described here, also not working. The terminal output is:
usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m | -g] [-x] [-I mask] [file ...]
What is the best solution?
Solution 1:
du -h -d 1
seems to work on my Mac
Solution 2:
Thanks to fd0, I was able to resolve the problem. The output
$ type -a du
du is aliased to 'du -sh'
du is /usr/bin/du
makes clear that the command du
was aliased to du -sh
. By removing this line from my .bash_profile
, everything works as it should. The solution e.g. by PeterVP works perfectly fine:
$ du -h -d 1