List directories and their sizes in Mac OS X command line [duplicate]

Solution 1:

With du you can compute the size of a directory:

du -hs dir

if you have only directories you can just (-h will return a human readable units, -s will not recurse)

du -hs *

if in the folder you have contains files and folders:

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

find will list all the directories (-type d) in the current folder (-mindepth 1 -maxdepth 1) and execute du on them.