Skip to content

Instantly share code, notes, and snippets.

@asauber
Forked from mlegenhausen/ds
Last active August 29, 2015 14:20
Show Gist options
  • Save asauber/144df158967843518bbe to your computer and use it in GitHub Desktop.
Save asauber/144df158967843518bbe to your computer and use it in GitHub Desktop.
#!/bin/sh
find $1 -type f -print0 | xargs -0 stat -f'%z' | awk '{b+=$1} END {print b}' | awk '{ sum=$1 ; hum[1024**3]="GB";hum[1024**2]="MB";hum[1024]="KB"; for (x=1024**3; x>=1024; x/=1024){ if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x];break } }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment