Disk Space Cleanup: Difference between revisions

From Psygen Wiki
Jump to navigation Jump to search
(Created page with " Find files that are using more than 1GB of space:<br /> <code>du -h / | grep ^[0-9\.]*G > diskusage; cat diskusage</code> More options:<br /> <code>function disk-space { d...")
 
No edit summary
 
Line 11: Line 11:


<code>disk - (tab complete)</code>
<code>disk - (tab complete)</code>
Find files that are taking up the most space, and sort by size:<br />
<code> du -hx /home/ --max-depth 1 | perl -e 'sub h{%h=(K=>10,M=>20,G=>30);($n,$u)=shift=~/([0-9.]+)(\D)/; return $n*2**$h{$u}}print sort{h($b)<=>h($a)}<>;'</code>

Latest revision as of 20:30, 25 October 2017


Find files that are using more than 1GB of space:
du -h / | grep ^[0-9\.]*G > diskusage; cat diskusage


More options:
function disk-space { du -sk ./* | sort -nr | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G"; pref[4]="T";} { 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]); }' }

disk - (tab complete)


Find files that are taking up the most space, and sort by size:
du -hx /home/ --max-depth 1 | perl -e 'sub h{%h=(K=>10,M=>20,G=>30);($n,$u)=shift=~/([0-9.]+)(\D)/; return $n*2**$h{$u}}print sort{h($b)<=>h($a)}<>;'