Friday 27 February 2009

Perl one-liner to summarize file sizes

ls -l /u02/volestlivelogs01/oradata/ESTDB/archive/*.dbf | sed -e "s/:/ /g" -e "s/  / /g" | perl -lane 'BEGIN {%hash=();} $hash{"$F[5]$F[6]-$F[7]:00"}+= $F[4]; END {foreach $k (sort keys %hash) {print "$k " . int($hash{$k}/(1024*1024)) . " Mb"; } }'

Total size of an arbitrary list of files

ls -lrt | grep "Feb 17" | awk '{tot += $5;ct +=1; print $9 " " $5/(1024*1024) "Mb"} END {printf(" Files : %s TOTAL SIZE %4.2f Gb\n",ct,tot/(1024*1024*1024))}'

Remove files

ls -lrt | grep "Feb 19" | cut -d":" -f2 | cut -d" " -f2 | xargs rm -rf


Wednesday 18 February 2009

Total size of an arbitrary list of files

ls -lrt | grep "Feb 17" | awk '{tot += $5;ct +=1; print $9 " " $5/(1024*1024) "Mb"} END {printf(" Files : %s TOTAL SIZE %4.2f Gb\n",ct,tot/(1024*1024*1024))}'