Revision: 4619
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 13, 2008 18:04 by amosshapira
Initial Code
#!/usr/bin/perl
$ARGV[0] = '.' unless @ARGV;
for my $dir (@ARGV) {
opendir DIR, $dir or die "$dir: $!\n";
$file =~ m:^\.: or ++$count
while ($file = readdir DIR);
closedir DIR;
}
print "$count\n";
exit 0;
Initial URL
Initial Description
In response to a very simplistic solution suggestion using Shell, here is a basic version of what I use. The advantage of the solution below is that it is supposed to be much faster on directories with many files (I regularly use its full-blown version on directories with tens and hundreds of thousands of files).
Initial Title
Count directory entries in given directories
Initial Tags
file, directory, perl
Initial Language
Perl