marconi_07 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Perl Script for checking and reporting file sizes in a directory.

Replies are listed 'Best First'.
Re: Perl Script for checking and reporting file sizes in a directory.
by moritz (Cardinal) on Apr 03, 2008 at 10:53 UTC

    You can get a list of files from a directory with opendir, readdir and closedir, or with glob.

    If you have a filename, -s $filename gives you the size.

    You should use File::Find to recursively traverse directories.

Re: Perl Script for checking and reporting file sizes in a directory.
by poolpi (Hermit) on Apr 03, 2008 at 12:02 UTC
    perl -we 'print map{ -f; (stat(_))[7], " bytes\n"; } <*.db>'


    hth,
    PooLpi

    'Ebry haffa hoe hab im tik a bush'. Jamaican proverb