I want a list of all the sub-directories and their total sizes. I can do it with the du -hs * command in CentOS and Ubuntu, but why doesn't it work on Mac?

This is the output I get:

MyMac:~ user$ du -hs *  
du: illegal option -- n   
usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k | -m | -g] [-x] [-I mask] [file ...]

As far as I know, * is a wildcard. Does macOS not support wildcards?

  • 1
    Related: What is the difference between "du -sh *" and "du -sh ./*"?. With GNU du (Ubuntu), you may prefer du -hd1 which will include hidden ones, skip non-directory files, also give the disk usage for . and work even if the list of files in the current directory is very large.
    – sch
    Oct 3, 2020 at 12:00

1 Answer 1


You probably have a file whose name begins with -n:

MyMac:~ user$ du -hs *
4.9G    Applications
1.1G    Desktop
2.2G    Documents
3.3G    Library
2.4M    Movies
7.8G    Music
 29G    Pictures
1.9G    Public
MyMac:~ user$ touch ./-none
MyMac:~ user$ du -hs *
du: illegal option -- n

Try du -hs -- *.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .