-
-
Save isa/8b80014d99ea0b02d919 to your computer and use it in GitHub Desktop.
Directory Usage script made pure with Unix functions
This file contains 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()}' | |
# captured from http://superuser.com/questions/602818/how-to-get-the-actual-directory-size-out-of-du |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment