BreadCrumbs: Bash Random Word

Bash Random Word

From Luke Jackson

Revision as of 01:19, 4 November 2006; Ljackson (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search

Contents

Summary

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

Supported Operating Systems

  • Mac OS X and Terminal
  • Unix
  • Linux

Requirements

  • 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.

Usage

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....

x=0
y=93
r=0

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"
done

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