Skip to content

Instantly share code, notes, and snippets.

@joostvanveen
Last active Jun 20, 2021
Embed
What would you like to do?
Get folder sizes on command line, including --max-depth, sorted by folder size desc
# Get available disk space
df -h
# Get the top 10 biggest folders in the current directory
du -h --max-depth=1 | sort -rh | head -10
# Get the top 10 biggest folders in the current directory and their first child directories
du -h --max-depth=2 | sort -rh | head -10
# Get sizes of all folders in the current directory
du -h --max-depth=2 | sort -rh
# On Mac OSX max depth 1
du -hd1 | sort -rh | head -10
# On Mac OSX max depth 2
du -hd2 | sort -rh | head -10
@johnb85022

This comment has been minimized.

Copy link

@johnb85022 johnb85022 commented Jun 18, 2021

Nice summary , thanks JB

@joostvanveen

This comment has been minimized.

Copy link
Owner Author

@joostvanveen joostvanveen commented Jun 20, 2021

Thanks, John

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment