Created
December 27, 2025 14:23
-
-
Save umutbasal/c6f66ed84be85ad892ef839f1209e272 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| ROOT="${1:-$(pwd)}" | |
| TARGETS=( | |
| node_modules | |
| target | |
| build | |
| dist | |
| venv | |
| .venv | |
| .gradle | |
| __pycache__ | |
| .next | |
| .nuxt | |
| .output | |
| vendor | |
| obj | |
| .turbo | |
| .parcel-cache | |
| ) | |
| # Build find expression | |
| FIND_EXPR=() | |
| for t in "${TARGETS[@]}"; do | |
| FIND_EXPR+=(-name "$t" -o) | |
| done | |
| # Bash doesn't support negative array indices; remove the trailing "-o" | |
| if ((${#FIND_EXPR[@]} > 0)); then | |
| unset "FIND_EXPR[$((${#FIND_EXPR[@]} - 1))]" | |
| fi | |
| # Scan + format | |
| find "$ROOT" -type d \( "${FIND_EXPR[@]}" \) -prune 2>/dev/null | | |
| while read -r dir; do | |
| size=$(du -sh "$dir" 2>/dev/null | awk '{print $1}') | |
| mtime=$(stat -f "%Sm" -t "%Y-%m-%d %H:%M" "$dir" 2>/dev/null || \ | |
| stat -c "%y" "$dir" 2>/dev/null | cut -d. -f1) | |
| printf "%-8s | %s | %s\n" "$size" "$mtime" "$dir" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment