Skip to content

Instantly share code, notes, and snippets.

@mcandre
Last active June 21, 2024 04:22
Show Gist options
  • Save mcandre/ebbdf2e445be0d810559 to your computer and use it in GitHub Desktop.
Save mcandre/ebbdf2e445be0d810559 to your computer and use it in GitHub Desktop.
Sort file and directories recursively by size

UNIX

Files: ls -lSh | tac

Directories: du -hd 1 | sort -h

Requires GNU coreutils (e.g., macOS users can run brew install coreutils).

macOS

Navigate to System Settings -> Storage.

Windows

Files and Directories: ls | select Name,@{n="Length"; e={[long](ls $_ -file -rec | measure Length -sum | % Sum)}} | sort Length -d }

Or navigate to Settings -> Storage -> Other.

Android

Navigate to Files -> Clean.

iOS / iPadOS

Navigate to Settings -> General -> Storage.

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