Skip to content

Instantly share code, notes, and snippets.

@staticor
Forked from joostvanveen/du.sh
Created January 6, 2021 04:07
Show Gist options
  • Save staticor/b088a9290699895d4786ce72ea966c70 to your computer and use it in GitHub Desktop.
Save staticor/b088a9290699895d4786ce72ea966c70 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment