Skip to content

Instantly share code, notes, and snippets.

@a1k0n
Created March 15, 2016 22:46
Show Gist options
  • Save a1k0n/c1d2e3c12aec03ff25a3 to your computer and use it in GitHub Desktop.
Save a1k0n/c1d2e3c12aec03ff25a3 to your computer and use it in GitHub Desktop.
clear a directory with a large number of files
use Time::HiRes qw(time);
opendir $d, ".";
$| = 1;
$n = 0;
$t0 = time;
while ($f = readdir $d) {
unlink $f;
$n++;
if ($n % 1000 == 0) {
printf("%d %f/sec\r", $n, $n / (time - $t0))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment