BreadCrumbs: Bash Random Word

Bash Random Word

From Luke Jackson

Jump to: navigation, search



A simple script that returns a random word from the local dictionary file.

Supported Operating Systems

  • Mac OS X and Terminal
  • Unix
  • Linux


  • Perl or $RANDOM
  • /usr/share/dict/words file
  • alias
  • Bash

How To

Simply edit your .profile file in your ~/ (home) directory and add the line below.

alias word='sed `perl -e "print int rand(99999)"`"q;d" /usr/share/dict/words'

Next reload your shell and thats it!

Now the next time you log in you can type word and a random word from the dictionary file will be displayed.


Now you ask what would I ever use this for?

That is simple silly, I like to use it when creating hundreds of directories on friends computers and watching them delete them with the mouse! HA HA

Something like this....


while [ "$x" -lt "$y" ]
do    # Do what $y says.
  r=`perl -e "print int rand(99999)"`
#  echo $r
  mkdir -v fun/`sed $r"q;d" /usr/share/dict/words`
  let "x = $x + 1"

Also this could be quite handy when generating passwords for ssh accounts.

No more lame passwords for you...although it is a mass distributed dictionary file...hmmm ya lets just stick with pointless folder creation.

Personal tools