Skip to content

Instantly share code, notes, and snippets.

@kunato
Forked from joostvanveen/du.sh
Created March 16, 2023 05:44
Show Gist options
  • Select an option

  • Save kunato/0380c6769aeb6addfca7b3f362eeaed4 to your computer and use it in GitHub Desktop.

Select an option

Save kunato/0380c6769aeb6addfca7b3f362eeaed4 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