Skip to content

Instantly share code, notes, and snippets.

@jiphex
Created October 27, 2011 10:23
Show Gist options
  • Save jiphex/1319227 to your computer and use it in GitHub Desktop.
Save jiphex/1319227 to your computer and use it in GitHub Desktop.
Count files in a (LARGE) directory
#!/usr/bin/perl
if (!defined($ARGV[0]) or ! -d $ARGV[0]) {
print "Supply a valid path\n";
}
opendir(THEDIR,$ARGV[0]);
my $counter = 0;
while (my $file = readdir(THEDIR)) {
$counter++;
}
closedir(THEDIR);
print "$counter $ARGV[0]\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment