Wednesday, April 13, 2016

OS X: Bash: Generating Random English Word

Command:

$ wcount=$[`wc -l < /usr/share/dict/words`];fromhead=$[$wcount - 1];random=$[`jot -r 1 0 $fromhead`];head -$[$random] /usr/share/dict/words | tail -1

Result:

everywhereness

Explaination:

Dictionary used: /usr/share/dict/words
Generating random line number: jot command