#!/usr/bin/perl -w use strict; if ($#ARGV != 2) { print STDERR "Usage: $0 prefix depth width\n\t$0 /mnt1 2 256\n"; exit 1; } my ($prefix, $maxdepth, $files) = @ARGV; my $print = 10_000; my $count = 0; my $total = 0; sub depth($$); sub depth($$) { my ($depth, $prefix) = @_; for my $i (0..$files-1) { my $p = $prefix . '/' . $i; if ($depth < $maxdepth) { mkdir $p or die "mkdir $p: $!"; depth($depth+1, $p); } else { open F, ">$p" or die "open $p: $!"; close F; unless (++$count % $print) { print STDERR "$count/$total files created\n" if -t STDERR; } } } } $total = $files**$maxdepth; depth (1, $prefix);