Random words from the terminal
Sep 05, '01 07:05:50AM
Contributed by: victory
Here's a nifty but somewhat useless quickie that will pick random words from the built-in dictionary file:
perl -e 'open IN, "</usr/share/dict/words";rand($.) < 1 && ($n=$_) while <IN>;print $n'
Notes:- Inspired by an example in the 'Camel' book and the fact that I couldn't come up with a non-Bash way to generate random numbers from the shell. (Any ideas why there's no /dev/random? It kinda seems that this was a design decision rather than an oversight...)
- The /usr/share/dict/words exists on most Unix systems. Curiously, the words seem to be different from that of the system-wide spellchecker service built into OSX.
- You can use the standard backtick operator to plop the word into another cmd-line program.
- DO NOT *EVER* USE THIS [OR ANY DICTIONARY] TO GENERATE PASSWORDS!
[To the editor: I admit this is sort of off-topic as far as Mac OSX is concerned. Perhaps you can use it when there's a dry spell in hints or as a 'stupid shell tricks' feature.]
[From the editor: Hey, it is a bit slow with everyone awaiting 10.1's arrival, and this is an interesting trick. There are some strange words in the dictionary!]
Comments (4)
Mac OS X Hints
http://hints.macworld.com/article.php?story=20010905070550180