Category Archives: Linux

Create files with certain size

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
Advertisements