cute utility - ckdsk
Posted in 1995
Pholks, Over the past couple of months I have been wrestling with disk space issues - namely there's never enough when I want it - it seems to be getting sucked up by others. Finding the files in question was a bear - going through du and tracking them down one by one. So - when the going gets tough the programmer writes a utility. Presenting ckdsk - no relation whatsoever to topics in this group - but I don't post to the admin groups - and I'm sure there are those of you out there who could use such. cheers j. _____________________________________________________________________________ Jack Parker - Hewlett Packard, BSMC Boise, Idaho, USA jparker@hpbs3645.boi.hp.com _____________________________________________________________________________ It ain't over till the digestively challenged lady sings. _____________________________________________________________________________ Any opinions expressed herein are my own and not those of my employers. _____________________________________________________________________________ ################################################################### # # Disk usage - report worst offenders # # $1 is the filesystem $2 is the number of files to report. # # Output: # # Owner size(KB) Path filename # # Jack Parker 5/95 # # HPUX 9x sort changed slightly with the keyfield designator - you may have # to alter this. # ################################################################### # load array with $2 worst directories i=1 du -x $1 | sort -n | tail -$2l | while read dskln do sz[$i]=`echo $dskln | awk '{print $1}'` # directory size dnm[$i]=`echo $dskln | awk '{print $2}'` # directory name let i=i+1 done # Do a long list and sort by filesize, cut off the last however many, format for fnm in ${dnm[*]} # foreach dir. do ll $fnm | # list files while read fthng do echo $fnm $fthng # concat path and filename done # sort unique, # ignore leading blanks, # sort numeric, # keyfield is field #6 (filesz) done | sort -u -b -n -k 6 | tail -n$2 | awk ' {printf("%-8s %12d %-31s %-15s\\n", $4, $6/1024, $1, $10) }'