Skip to content

Instantly share code, notes, and snippets.

@do-me
Created February 16, 2026 15:58
Show Gist options
  • Select an option

  • Save do-me/50005aec449f3513a1f0fdfb46786557 to your computer and use it in GitHub Desktop.

Select an option

Save do-me/50005aec449f3513a1f0fdfb46786557 to your computer and use it in GitHub Desktop.
Get size of dir, number of files and average file size
read s c < <(find images -type f -printf '%s\n' 2>/dev/null | awk '{t+=$1} END{print t, NR}'); printf "Total size: %s\nFiles: %d\nAverage: %s\n" "$(numfmt --to=iec --suffix=B $s)" "$c" "$(numfmt --to=iec --suffix=B $((c? s/c : 0)))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment