#!/bin/bash if [ -z "$*" ]; then echo "usage: $0 (age)" echo " will display size of dirs containing old files and the" echo " percentage of space those files take up of that dir." echo " Run from top dir of tree you wish to look at." echo echo " Age can be in any format that CVS accepts (as per find's" echo " limits on dates for -newer*t) eg 'yesterday' '6 months ago'" echo echo " WARNING: HOLEY FILES in FreeBSD will confuse $0." echo exit fi (find . ! -newerat "$*" -a -ls 2> /dev/null | awk '{print $7," ",$11," ",$12," ",$13," ",$14, \ " ", $15, " ", $16, " ", $17," ",$18," ",$19," ",$20," ",$21, \ " ",$22, " ", $23, " ", $23, " ", $24, " ", $25}' | tr -s " " | perl -ane '{$size=shift @F; $n=join(" ",@F); $n =~ s#/[^/]*$##; $d{$n}+=$size} END { for $a (sort { $d{$a} <=> $d{$b} } keys %d) { print "$d{$a}\t$a\n" } }' | sort -rn | while read a; do size=`echo $a | cut -d" " -f1` name=`echo $a | cut -d" " -f2-` total=`du -ks "$name" | cut -d" " -f1` echo $[ $size/1000]K $[ ($size/10) / $total-2]% $name done ) 2> /dev/null