Re: how to find average file size



On 15 Jan 2006 11:48:11 -0800, jim.frantzen@xxxxxxxxx staggered into the
Black Sun and said:
> I have a reiserFS under Mandrake with a directory, full of
> subdirectories, in total containing 15 million small image files
> (between 1k and 10k). How can I find the average file size?

cd /path/to/where/images/are
find . -type f -print > /somewhere/allfiles.txt
(NOTE: put this file somewhere that isn't in or under the current
directory, as it'll screw up the calculations we want to do.)
wc -l /somewhere/allfiles.txt
(tells you how many files you have, remember this number)
perl -e 'while($file=<>){ chomp $file; $total += -s $file; } print
"total in bytes = $total\n"; ' < /somewhere/allfiles.txt
(does -s on each file, adds file size up, prints it out.)

Divide total in bytes by number of files to get mean size. If you
wanted median size or mode size, that requires a little more/different
work.

--
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Brainbench MVP for Linux Admin / mail: TRAP + SPAN don't belong
http://www.brainbench.com / "He is a rhythmic movement of the
-----------------------------/ penguins, is Tux." --MegaHAL
.



Relevant Pages

  • how to find average file size
    ... I have a reiserFS under Mandrake with a directory, full of sub ... in total containing 15 million small image files (between ...
    (comp.os.linux.misc)
  • Directory with large number of files
    ... of the files are in one of the subdirectories. ... The files are image files, ... The machine has 2 GB RAM. ... What would be a reasonable setting for vfs.ufs.dirhash_maxmem? ...
    (freebsd-questions)
  • Re: directories do not shrink automatically
    ... Then you are using the wrong file system, ... subdirectories. ... I'm using Ext3, having tried ReiserFS before. ...
    (comp.os.linux.misc)
  • Re: File system under Linux
    ... My guess is Reiserfs, ... I previously had installed Reiserfs on my other computer, ... time I could create it with the installation-cd of Kubuntu. ... I cannot find reiser as a possibility on my Mandrake either so it may not ...
    (comp.os.linux.misc)
  • Re: How to make this simple script?
    ... 2005-05-11, 19:02, Ying Zu: ... > In my picture dir, there are a lot of image files with the names like ... To recurse in subdirectories: ...
    (comp.unix.shell)