diff --git a/d6.sh b/d6.sh index f49bc05..1280b72 100755 --- a/d6.sh +++ b/d6.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # This is free and unencumbered software released into the public domain. # # Anyone is free to copy, modify, publish, use, compile, sell, or @@ -86,7 +86,33 @@ do esac done -echo "NUM_WORDS=$NUM_WORDS" -echo "WORDLIST=$WORDLIST" -echo "DELIMITER=$DELIMITER" -echo "CASE=$CASE" +WORDS="" + +for i in $(seq 1 $NUM_WORDS) +do + ROLLS="" + for j in {1..5} + do + ROLLS="$((1 + $RANDOM % 6))$ROLLS" + done + + if [ $CASE == "upper" ] + then + WORD="$(awk "/$ROLLS/{ print toupper(\$2) }" $WORDLIST)" + elif [ $CASE == "lower" ] + then + WORD="$(awk "/$ROLLS/{ print tolower(\$2) }" $WORDLIST)" + else + WORD="$(awk "/$ROLLS/{ print \$2 }" $WORDLIST)" + WORD="${WORD^}" + fi + + if [ $i -eq $NUM_WORDS ] + then + WORDS="${WORDS}${WORD}" + else + WORDS="${WORDS}${WORD}${DELIMITER}" + fi +done + +echo "$WORDS"