__/ [Grant Edwards] on Sunday 15 January 2006 23:33 \__
> On 2006-01-15, Roy Schestowitz <newsgroups@xxxxxxxxxxxxxxx> wrote:
>> __/ [jim.frantzen@xxxxxxxxx] on Sunday 15 January 2006 19:48 \__
>>> I have a reiserFS under Mandrake with a directory, full of sub
>>> directories, in total containing 15 million small image files (between
>>> 1k and 10k).
>>> How can I find the average file size?
>> Go to the parent directory
>> 'du -sh' gives you the size of all files therein
> No, that gives the amount of disk space used by all the files.
> Disk usage and file size are not the same thing.
>> 'find . -type f | wc -l' gives you the total number of files
>> Divide the output of the first by the second
> That will be an upper bound on the average file size, but
> (especially if the files are small), it may not be a very close
> $ mkdir foo
> $ echo "hi" >foo/bar
> $ du -sh foo
> 8.0K foo
> $ ls -l foo
> total 4
> -rw-r--r-- 1 grante grante 3 Jan 15 17:32 bar
> The average file size is 3. Your solution yields the value
Excellent point and an elegant example, but I thought an approximation would
be sufficient. I have an alias set up for "number of files" and I am often
contented enough with "du -sh". Your point still hold though. I don't know
how small the OP's images actually are.