#!/bin/bash # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # Version 2, December 2004 # # Copyright (C) 2011 Emmanuel Revah # # Everyone is permitted to copy and distribute verbatim or modified # copies of this license document, and changing it is allowed as long # as the name is changed. # # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION # # 0. You just DO WHAT THE FUCK YOU WANT TO. ##### Config (uration) ##### # QTY of files to create QTY=500 # Where to create new files ? OUTPUT="/tmp" # Min and Max size per file in kB MIN=10 MAX=1000 # Max number of directories to create MAXDIR=500 ############## END CONFIG ############# # Correct MIN and MAX and check MAX=`expr $MAX - $MIN + 1` if [[ ${MAX} < 0 ]]; then echo "ERROR: MAX is lower than MIN, and vice versa." exit fi for i in $(seq 1 $QTY); do echo "File number -> $i" DDCOUNT=$[ ( $RANDOM % $MAX ) + $MIN ] DIR=$[ ( $RANDOM % $MAXDIR ) + 1 ] # uncomment and use "$OUTPUT/$DIR/${i}_$FILENAME" to avoid rewriting over previous random files #FILENAME=`head -n1 /dev/urandom | md5sum| awk {'print $1'}` if [ ! -d $OUTPUT/$DIR ]; then mkdir -p $OUTPUT/$DIR fi dd bs=1024 count=$DDCOUNT skip=0 if=/dev/urandom of=$OUTPUT/$DIR/${i} 2> /dev/null done