Functional code.

This commit is contained in:
Nicolás Ortega Froysa 2020-11-12 14:07:16 +01:00
parent 923ca7f055
commit ff0632fc0f

36
d6.sh
View File

@ -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"