Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: quickest way to find number of files in a directory?

by ferreira (Chaplain)
on Mar 27, 2007 at 17:36 UTC ( #606814=note: print w/replies, xml ) Need Help??


in reply to Re: quickest way to find number of files in a directory?
in thread quickest way to find number of files in a directory?

Nit-picking: the dot files (like ".bashrc") are not counted when using the glob.

Replies are listed 'Best First'.
Re^3: quickest way to find number of files in a directory?
by Anonymous Monk on Mar 27, 2007 at 20:22 UTC
    That depends on your shells. At least under bash, you can use glob() to grab dot files, for example:
      print "$_\n" for grep{ -f } glob(".*");
    
    Or probably if you want to grab both dot and non-dot files:
      print "$_\n" for grep{ -f } glob("{*,}.*");
    
    Regards,
    Xicheng

      Nope. It does not depend on your shell. At least not if you're using Perl 5.6 or later, because glob is implemented via the standard File::Glob extension and does not rely on shell anymore.

      The standard behavior of <*> or glob('*') is to not consider the dot files.

        In the example given, glob is not used with '*'.
Re^3: quickest way to find number of files in a directory?
by Anonymous Monk on Jul 24, 2012 at 15:38 UTC
    is it efficient with more than 100 000 files in the directory ? if I well understand the code, each inode is loaded in memory... so do you know another mean to get this count, without need of a huge memory ?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2019-03-20 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How do you Carpe diem?





    Results (103 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!