buymeasoda RefDocs
  • Overview
  • General
    • Android
    • Apache
    • Fish
    • Git
    • Github
    • Gmail
    • Homebrew
    • iOS
    • iTerm
    • MacOS
    • MacPorts
    • Mamp
    • Media
    • Mercurial
    • MySQL
    • Node
    • npm
    • nvm
    • Obsidian
    • PHP
    • React Native
    • Rust
    • Server
    • Slack
    • Sourcegraph
    • Tools
    • Vim
    • VS Code
    • Yarn
  • Unix
    • Checksum and hash utilities
    • Command line history
    • Command line keyboard shortcuts
    • Compress files and folders
    • Crontab
    • Diff files and folders
    • Disk usage and file sizes
    • Find and search files
    • Firewall configuration
    • Help and manual pages
    • HostName and Local HostName for Mac OSX
    • Navigating the file system
    • Network, domains and routing
    • Run and manage background tasks
    • Secure FTP SFTP and Secure Copy SCP
    • Secure Shell SSH
    • Sync files and folders
    • System and process management
    • System and user information
    • Useful characters
    • Useful commands
    • User, file and group permissions
    • Working with cURL
    • Working with files and directories
    • Working with text
Powered by GitBook
On this page
  1. Unix

Disk usage and file sizes

Calculate total disk usage / size for a folder

du -sh <folder>

Ignore specified files and directories when calculating size

du -sh -I <ignore-pattern> <folder>

Show disk space usage and available space (-h makes the output human readable values)

df -h

Usage Examples

Find files under the root directory and below that are larger than 10 MB (optionally ignore .git directories)

find <path> -size +10M
find <path> -size +10M -not -path '*/\.git/*'

Format output when using GNU find (Note: -printf is not POSIX)

find <path> -size +10M -printf "%s - %p\n"

Show ten largest files and directories under current location

du . | sort -nr | head -n10
du -s * | sort -nr | head -n10

Calculate size of files in git repo (ignoring git directory)

du -sh -I .git <folder>
PreviousDiff files and foldersNextFind and search files

Last updated 1 year ago