Use this expanded command to get a better view of sorted file sizes:
root@server# du -sk ./* | sort -nr | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'
6.3G ./lib 2.1G ./share 320.8M ./src 246.9M ./bin 41.2M ./sbin 29.9M ./include 17.4M ./libexec 6.5M ./local 24K ./games 4K ./libx32 4K ./lib64 4K ./lib32 Total: 8.1G
This is a super nice one-liner! Bookmarked!
Thanks man :D
This is sick!
used it since like 2009 when I needed to seperate a large folder containing thousands of file :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Use this expanded command to get a better view of sorted file sizes:
root@server# du -sk ./* | sort -nr | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'
6.3G ./lib
2.1G ./share
320.8M ./src
246.9M ./bin
41.2M ./sbin
29.9M ./include
17.4M ./libexec
6.5M ./local
24K ./games
4K ./libx32
4K ./lib64
4K ./lib32
Total: 8.1G
This is a super nice one-liner! Bookmarked!
Thanks man :D
This is sick!
used it since like 2009 when I needed to seperate a large folder containing thousands of file :)