Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How to find folder size

by davorg (Chancellor)
on Jul 08, 2009 at 09:47 UTC ( [id://778173]=note: print w/replies, xml ) Need Help??


in reply to How to find folder size

-s returns the size of a file (even if that file is a directory). If you want to sum the sizes of the files within a directory then you'll probably want something like File::Find.

--

See the Copyright notice on my home node.

Perl training courses

Replies are listed 'Best First'.
Re^2: How to find folder size
by spx2 (Deacon) on Jul 08, 2009 at 10:11 UTC
    or you can just parse output of du -csh <directory>
      Not very portable though - better to stick to davorg solution.
        Note that davorg suggested using -s, which for a directory tells you the size of the directory entry itself - which grows (but in many filesystems doesn't shrink) with the number of files. The size reported does not have any relation at all with the sum of the sizes of the files inside a directory. Which to me, seems what the OP wants.

        Note that even using -s to sum the sizes of the files in a directory has its problems - you have consider symlinks and hardlinks. The former may cause loops, or point to a totally different part of the filesystem, while hardlinks may cause you to count files two or more times if you aren't tracking inodes.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://778173]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-19 10:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found