2012-11-19

Dump average file size within a directory

I had to provide some stats about feed files and found below time saving command here http://vivekjain10.blogspot.com/2008/02/average-file-size-within-directory.html

1:  find /some/dir -type f -name *.txt \  
2:  -print0 | xargs -0 ls -l | gawk \  
3:  '{sum += $5; n++;} END {print "Total Size: " sum/1024/1024 " MB : Avg Size: " sum/n/1024 " KB : Total Files: " n ;}'  
4:    
5:  Total Size: 55214.8 MB : Avg Size: 9792.17 KB : Total Files: 5774