How du I get the disk size of a directory?

December 23rd, 2017 | #bash

Typo in the title? Well, not really, because command du displays the disk usage statistics.

du has several options. However, to get the disk size of a directory, there are two options you should use:

-s      Display an entry for each specified file.


-h      "Human-readable" output.  Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte.

du in action

$ du -sh /Volumes/WORKSPACE/
 20G    /Volumes/WORKSPACE/

If we do not use -h, du will not print a human-readable output:

$ du -s /Volumes/WORKSPACE/
41267840    /Volumes/WORKSPACE/

To check more than one directory—and see the total—use du -sch:

-c      Display a grand total.

Read more about du with:

$ man du

© 2018 Tonny Garić | With from Nijmegen, The Netherlands