Re: how to find average file size
- From: Dances With Crows <danSPANceswitTRAPhcrows@xxxxxxxxx>
- Date: Sun, 15 Jan 2006 14:18:37 -0600
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
.
- References:
- how to find average file size
- From: jim . frantzen
- how to find average file size
- Prev by Date: Re: how to find average file size
- Next by Date: Re: Yet Another Recommendation Request: Noob, user (not server), just to fool around...
- Previous by thread: Re: how to find average file size
- Next by thread: Clear Thinking Power for Comp Developers
- Index(es):
Relevant Pages
|