Created
December 30, 2014 12:20
-
-
Save jonman364/49725709a2be7e841b44 to your computer and use it in GitHub Desktop.
du without du
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/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