Skip to content

Instantly share code, notes, and snippets.

@inhumantsar
Created November 30, 2022 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inhumantsar/1e7bc880daa9041be9396a6ef03d2dbf to your computer and use it in GitHub Desktop.
Save inhumantsar/1e7bc880daa9041be9396a6ef03d2dbf to your computer and use it in GitHub Desktop.
Generate file size distribution on the commandline
# from https://superuser.com/a/1100340
find . -type f -print0 | xargs -0 ls -l | awk '{ n=int(log($5)/log(2)); if (n<10) { n=10; } size[n]++ } END { for (i in size) printf("%d %d\n", 2^i, size[i]) }' | sort -n | awk 'function human(x) { x[1]/=1024; if (x[1]>=1024) { x[2]++; human(x) } } { a[1]=$1; a[2]=0; human(a); printf("%3d%s: %6d\n", a[1],substr("kMGTEPYZ",a[2]+1,1),$2) }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment