{"id":26581580,"url":"https://github.com/open-technology-foundation/dux","last_synced_at":"2025-10-07T02:06:49.818Z","repository":{"id":283199139,"uuid":"950977811","full_name":"Open-Technology-Foundation/dux","owner":"Open-Technology-Foundation","description":"A fast and efficient Bash utility for analyzing and displaying directory sizes in human-readable format.","archived":false,"fork":false,"pushed_at":"2025-09-21T02:40:06.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-07T02:04:47.760Z","etag":null,"topics":["bash","disk-usage"],"latest_commit_sha":null,"homepage":"https://yatti.id/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Open-Technology-Foundation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-19T01:20:18.000Z","updated_at":"2025-09-21T02:40:09.000Z","dependencies_parsed_at":"2025-09-21T04:14:27.756Z","dependency_job_id":"7329d9a5-3f47-425f-9fb0-da4fc2e46ef0","html_url":"https://github.com/Open-Technology-Foundation/dux","commit_stats":null,"previous_names":["open-technology-foundation/dux"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Open-Technology-Foundation/dux","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fdux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fdux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fdux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fdux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Open-Technology-Foundation","download_url":"https://codeload.github.com/Open-Technology-Foundation/dux/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Open-Technology-Foundation%2Fdux/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278708004,"owners_count":26031932,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","disk-usage"],"created_at":"2025-03-23T07:21:33.400Z","updated_at":"2025-10-07T02:06:49.811Z","avatar_url":"https://github.com/Open-Technology-Foundation.png","language":"Shell","readme":"# dir-sizes - Directory Size Analyzer\n\n[![Bash](https://img.shields.io/badge/language-Bash-green.svg)](https://www.gnu.org/software/bash/)\n[![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg)](LICENSE)\n\nA fast and efficient Bash utility for analyzing and displaying directory sizes in human-readable format.\n\n## Overview\n\n`dir-sizes` is a streamlined directory size analyzer that calculates the total size of each subdirectory within a specified directory. It presents the results sorted by size in an easy-to-read format, making it simple to identify which directories are consuming the most disk space.\n\n## Features\n\n- **Recursive Size Calculation**: Accurately calculates the total size including all nested subdirectories\n- **Human-Readable Output**: Automatically converts bytes to appropriate units (KB, MB, GB, etc.)\n- **Sorted Results**: Displays directories sorted by size (smallest to largest) for easy analysis\n- **Permission Handling**: Gracefully handles permission errors, showing warnings while continuing execution\n- **Fast Performance**: Efficient implementation using native `du` command\n- **Standards Compliant**: Follows strict BASH coding standards for reliability and safety\n- **Security Hardened**: Implements PATH locking, secure temp files, and proper signal handling\n\n## Installation\n\n1. Clone this repository:\n   ```bash\n   git clone https://github.com/username/dux.git\n   cd dux\n   ```\n\n2. Make the script executable:\n   ```bash\n   chmod +x dir-sizes\n   ```\n\n3. Optionally, add to your PATH:\n   ```bash\n   # Add to ~/.bashrc or ~/.bash_profile\n   export PATH=\"$PATH:/path/to/dux\"\n   ```\n\n   Or create a symlink:\n   ```bash\n   sudo ln -s /path/to/dux/dir-sizes /usr/local/bin/dir-sizes\n   ```\n\n## Usage\n\nBasic usage:\n```bash\ndir-sizes [directory]\n```\n\n### Examples\n\n```bash\n# Analyze current directory\ndir-sizes\n\n# Analyze specific directory\ndir-sizes /var\n\n# Analyze and show only the 10 largest directories\ndir-sizes /usr | tail -10\n```\n\n### Command-Line Options\n\n```\nOptions:\n  -h, --help     Display help message and exit\n  -V, --version  Display version information and exit\n\nArguments:\n  directory      Directory to analyze (defaults to current directory)\n```\n\n### Output Format\n\n```\n\u003csize\u003e  \u003cpath\u003e\n```\n\nWhere:\n- `\u003csize\u003e` is the human-readable size with IEC units (e.g., 128.5MiB, 1.2GiB)\n- `\u003cpath\u003e` is the absolute or relative path to the directory\n\nExample output:\n```\n0.0B      \t./.cache\n56.7KB    \t./.git\n102.6KB   \t./src\n1.5MB     \t./docs\n23.4MB    \t./data\n```\n\n## Behavior\n\n### Size Calculation\n- Uses `du -sb` to calculate actual disk usage in bytes\n- Includes all nested subdirectories in the size calculation\n- Provides the total recursive size for each immediate subdirectory\n\n### Permission Handling\n- Permission errors are reported to stderr but don't stop execution\n- Directories that can't be fully read show the size of accessible contents\n\n### Performance Notes\n- Large directories with many files may take time to analyze\n- The script must recursively calculate sizes, which involves reading directory metadata\n- For very large filesystems, consider analyzing specific subdirectories\n\n## Exit Codes\n\n- `0` - Success\n- `1` - General error (invalid directory, complete failure)\n- `22` - Invalid command-line option\n\n## Requirements\n\n- Bash 5.2 or higher (uses modern Bash features)\n- GNU coreutils 8.32+ (for numfmt IEC units)\n- GNU coreutils (`du`, `cut`, `sort`, `numfmt`)\n- Standard POSIX utilities\n\n## Technical Details\n\nThe script follows strict BASH coding standards (v1.2.0 improvements):\n- Uses `set -euo pipefail` with `shopt -s inherit_errexit` for robust error handling\n- Implements proper variable scoping with typed declarations (`declare -i`, `declare --`)\n- Secure temporary file handling with `mktemp` and automatic cleanup via traps\n- PATH security hardening to prevent command injection\n- Signal handling for clean interruption (SIGINT, SIGTERM)\n\n## Comparison with Similar Tools\n\n| Feature | dir-sizes | du | ncdu | dust |\n|---------|-----------|-----|------|------|\n| Human-readable | ✓ (IEC) | With -h | ✓ | ✓ |\n| Sorted output | ✓ | With sort | ✓ | ✓ |\n| Interactive | ✗ | ✗ | ✓ | ✗ |\n| Recursive totals | ✓ | ✓ | ✓ | ✓ |\n| Security hardened | ✓ | ✗ | ✗ | ✗ |\n| Signal handling | ✓ | ✗ | ✓ | ✗ |\n| Dependencies | Minimal | None | ncurses | Rust |\n| Speed | Fast | Fast | Moderate | Fast |\n\n## Troubleshooting\n\n### Permission Denied Errors\nIf you see many \"Permission denied\" errors:\n```bash\n# Run with sudo for system directories\nsudo dir-sizes /var\n\n# Or suppress errors (not recommended, total sizes will be incorrect)\ndir-sizes /var 2\u003e/dev/null\n```\n\n### Slow Performance\nFor very large directories:\n```bash\n# Analyze specific subdirectories instead\ndir-sizes /large/dir/specific-subdir\n\n# Use timeout to limit execution time\ntimeout 30 dir-sizes /very/large/dir\n```\n\n## Development\n\n### Running Tests\n```bash\n# Basic functionality test\ndir-sizes /tmp\n\n# Test with various directories\nfor dir in /tmp /var/log /home; do\n  echo \"Testing $dir:\"\n  dir-sizes \"$dir\" 2\u003e/dev/null | head -5\ndone\n```\n\n### Code Style\nThis project follows the organization's BASH coding standards as defined in [BASH-CODING-STYLE](https://github.com/Open-Technology-Foundation/bash-coding-standard), including:\n- Proper shebang (`#!/bin/bash`) with script description\n- Critical safety settings (`inherit_errexit`, `shift_verbose`, `extglob`, `nullglob`)\n- Consistent variable declarations with proper typing\n- Standard utility functions (error handling, messaging)\n- Comprehensive inline and usage documentation\n- Security-first approach (PATH locking, mktemp usage)\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0 (GPL-3.0) - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- Built on GNU coreutils' robust `du` command\n- Follows best practices from the Bash scripting community\n- Inspired by the need for a simple, fast directory size analyzer\n\n## See Also\n\n- `du(1)` - The underlying disk usage command\n- `ncdu` - Interactive ncurses-based disk usage analyzer\n- `dust` - Modern du replacement written in Rust\n- `duf` - Modern df replacement with better UI\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-technology-foundation%2Fdux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-technology-foundation%2Fdux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-technology-foundation%2Fdux/lists"}