#! /bin/bash # Makes a file with a number of key values START=$(date +%s) BASE=$(dirname $(dirname $(realpath -s $0))); AMOUNT=1000 FILE_NAME="corpus.csv" FULL_PATH="$BASE/csv/$FILE_NAME" if [ -f "$FULL_PATH" ]; then rm "$FULL_PATH" fi echo "Generating csv/$FILE_NAME..." KEY_LEN=${#AMOUNT} LINE_LEN=`expr 100 - $KEY_LEN` for (( i = 0; i < "$AMOUNT"; i++ )); do KEY=$(printf "%0${KEY_LEN}d\n" $i) LEN1=$(shuf -i "0-$LINE_LEN" -n 1) LEN2=`expr 100 - $LEN1` PART1=$(shuf -er -n "$LEN1" {a..z} | paste -sd "") PART2=$(shuf -er -n "$LEN2" {a..z} | paste -sd "") echo "$PART1$KEY$PART2" >> $FULL_PATH done shuf "$FULL_PATH" > "$BASE/tmp.csv" && mv "$BASE/tmp.csv" "$FULL_PATH" END=$(date +%s) SECONDS=`expr $END - $START` echo "$FILE generated in ${SECONDS}s"