Create multiple empty files #
The following examples create three empty files of 1MB each:
Unix:
$ for i in {1..3}; do dd if=/dev/zero of=/path/$i bs=1m count=1; done
or,
$ for i in {1..3}; do mkfile 1m /path/$i; done
Windows:
C:\>for /L %x in (1,1,3) do fsutil file createnew %x 1048576
Notes:
- mkfile can generate sparse files with the -n option.
- The Windows for loop set is (start,step,end).
- See also Generate Files with Random Content and Size in Bash, which introduces this script:
no_of_files=10;
counter=1;
while [[ $counter -le $no_of_files ]];
do echo Creating file no $counter;
dd bs=1024 count=$RANDOM skip=$RANDOM if=/dev/sda of=random-file.$counter;
let "counter += 1";
done
/nix | Nov 13, 2009
Subscribe or visit the archives.