What it does: The script will create certain number of files with certain size. It takes two arguments – first is the number of files and the second is the size of each file ( in kilobytes ).
Usage: ./script.sh 100 1
(this will create 100 files 1MB each)
Code:
#!/bin/bash filecount=$1; blocksize=$2; counter=1; while [[ $counter -le $filecount ]]; do echo Copying $counter; dd if=/dev/zero of=filename$counter bs=$2k count=1024 let "counter +=1"; done
I’d prefer using ARITHMETIC EVALUATION:
and prefixing 0 to the filenames:
and maybe using
for
for clearer code:Great ! (: and thank you for “code language bash” :). Post update thanks to http://www.yjl.im/ .