#!/bin/bash
# Initial version has been created by Arsen Kairkanov 11 August 2014

DIRECTORY_NAME=$1
DIRECTORY_SIZE=$2
AVERAGE_SIZE=$3
DISPERSION=$4
SAMPLE_DESTINATION=$5
if [ $# -lt 4 ]
then
cat <<END
$0: The script is dedicated to generate the directory with a number of files \
of different sizes with defined average length and defined dispersion of the \
length.
Usage: $0 DIRECTORY_NAME DIRECTORY_SIZE(KB) AVERAGE_SIZE(KB) DISPERSION SAMPLE_DESTINATION
END
exit 1
fi
NUMBER_OF_FILES=$(( $DIRECTORY_SIZE / $AVERAGE_SIZE ))
#SAMPLE_SIZE=`du -k $SAMPLE_DESTINATION | awk '{print $1}'`
mkdir $DIRECTORY_NAME
cd $DIRECTORY_NAME

COUNT=1
while [ $COUNT -le $NUMBER_OF_FILES ]
do
SIZE=`python -S -c "import random; print int(random.gauss($AVERAGE_SIZE, $DISPERSION)) "`
dd if=/dev/urandom of=$COUNT bs=1K count=$SIZE
COUNT=$[$COUNT + 1]
done

ls -lt --block-size=1M