aboutsummaryrefslogtreecommitdiffstats
path: root/SOURCE/CORE/helpers.sh
diff options
context:
space:
mode:
Diffstat (limited to 'SOURCE/CORE/helpers.sh')
-rw-r--r--SOURCE/CORE/helpers.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/SOURCE/CORE/helpers.sh b/SOURCE/CORE/helpers.sh
index 565413d..567846b 100644
--- a/SOURCE/CORE/helpers.sh
+++ b/SOURCE/CORE/helpers.sh
@@ -51,3 +51,25 @@ __NOWCONF__
}
+# this function returns a random 2 words title
+function random_title() {
+ # Constants
+ X=0
+ DICT=/usr/share/dict/words
+ OUTPUT=""
+
+ # total number of non-random words available
+ COUNT=$(cat $DICT | wc -l)
+
+ # while loop to generate random words
+ while [ "$X" -lt 2 ]
+ do
+ RAND=$(od -N3 -An -i /dev/urandom | awk -v f=0 -v r="$COUNT" '{printf "%i\n", f + r * $1 / 16777216}')
+ OUTPUT+="$(sed `echo $RAND`"q;d" $DICT)"
+ (("X = X + 1"))
+ [[ $X -eq 1 ]] && OUTPUT+=" "
+ done
+
+ echo $OUTPUT
+}
+