Created
March 15, 2016 22:46
-
-
Save a1k0n/c1d2e3c12aec03ff25a3 to your computer and use it in GitHub Desktop.
clear a directory with a large number of files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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