Skip to content

Instantly share code, notes, and snippets.

@jonman364
Created December 30, 2014 12:20
Show Gist options
  • Save jonman364/49725709a2be7e841b44 to your computer and use it in GitHub Desktop.
Save jonman364/49725709a2be7e841b44 to your computer and use it in GitHub Desktop.
du without du
#!/bin/sh
find ${1:-.} -type f -exec ls -lnq {} \+ | awk '
function pp() {
u="+Ki+Mi+Gi+Ti";
split(u,unit,"+");
v=sum;
r=0;
for(i=1;i<5;i++) {
if(v<1024) break;
r=v%1024;
v/=1024;
}
printf("%.3f %sB\n",v+r/1024.,unit[i]);
}
{sum+=$5}
END{pp()}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment