Created
April 23, 2020 05:24
-
-
Save orirawlings/bb66b0b5d99ebdf9fdbc305752fa5621 to your computer and use it in GitHub Desktop.
Generate random backronyms using the dictionary at /usr/share/dict/words
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN { | |
while((getline < "/usr/share/dict/words") > 0) { | |
first = substr($0, 1, 1) | |
wordcnts[first]++ | |
words[first,wordcnts[first]] = $0 | |
} | |
srand() | |
} | |
{ | |
len = length($0) | |
for (i=1; i<=len; i++) { | |
l = substr($0, i, 1) | |
word = words[l,int(rand()*wordcnts[l])+1] | |
printf "%s%s", word, (i < len ? " " : "\n") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment