Casey West > ppt-0.14 > fortune


Annotate this POD


Open  5
View/Report Bugs


fortune - print a random, hopefully interesting, adage


fortune [-adefgilosw] [-m pattern] [[N%] file/dir/all]


When fortune is run with no arguments it prints out a random epigram. Epigrams are divided into several categories, where each category is sub- divided into those which are potentially offensive and those which are not. The options are as follows:

     -a    Choose from all lists of maxims, both offensive and not.  (See the
           -o option for more information on offensive fortunes.)

     -e    Consider all fortune files to be of equal size (see discussion be-
           low on multiple files).

     -f    Print out the list of files which would be searched, but do not
           print a fortune.

     -l    Long dictums only.  Long is defined as 200 or more charaters.

     -m    Print out all fortunes which match the regular expression pattern.
           See regex(3) for a description of patterns.

     -o    Choose only from potentially offensive aphorisms.  Please, please,
           please request a potentially offensive fortune if and only if you
           believe, deep down in your heart, that you are willing to be of-
           fended.  (And that if you are, you'll just quit using -o rather
           than give us grief about it, okay?)

                 ... let us keep in mind the basic governing philosophy of The
                 Brotherhood, as handsomely summarized in these words: we be-
                 lieve in healthy, hearty laughter -- at the expense of the
                 whole human race, if needs be.  Needs be.
                             --H. Allen Smith, "Rude Jokes"

     -s    Short apothegms only.  Short is defined as less than 200 charaters.

     -i    Ignore case for -m patterns.

     -w    Wait before termination for an amount of time calculated from the
           number of characters in the message.  This is useful if it is exe-
           cuted as part of the logout procedure to guarantee that the message
           can be read before the screen is cleared.

     The user may specify alternate sayings.  You can specify a specific file,
     a directory which contains one or more files, or the special word all
     which says to use all the standard databases.  Any of these may be pre-
     ceded by a percentage, which is a number N between 0 and 100 inclusive,
     followed by a %. If it is, there will be a N percent probability that an
     adage will be picked from that file or directory.  If the percentages do
     not sum to 100, and there are specifications without percentages, the re-
     maining percent will apply to those files and/or directories, in which
     case the probability of selecting from one of them will be based on their
     relative sizes.

     As an example, given two databases funny and not-funny, with funny twice
     as big, saying

           fortune funny not-funny

     will get you fortunes out of funny two-thirds of the time.  The command

           fortune 90% funny 10% not-funny

     will pick out 90% of its fortunes from funny (the ``10% not-funny'' is
     unnecessary, since 10% is all that's left).  The -e option says to con-
     sider all files equal; thus

           fortune -e

     is equivalent to

           fortune 50% funny 50% not-funny


fortune readme ./fortunes ./fortunes/fortunes1 ./fortunes/fortunes2-o ./fortunes/fortunes2 ./fortunes/limerick ./fortunes/lwall ./fortunes/startrek ./fortunes/zippy


The matching is only working 50% of the time using single quotes around strings with white space and not at all for double quotes.

Command line input of files does not work.


Get the command line args of files and percentages to work.


        Revision 1.0.1 1999/06/07 andy murren
        Small fixes and code clean up
        FindBin now helps locate the directory of fortunes
        Will search multiple files for a match
        Dumped the -g option I tried in the original

        Revision 1.0 1999/04/01 andy murren
        Inital Revision


This Perl implmentation of fortune was written by Andy Murren,


This program is covered by the GNU Public License (GPL). See for complete detail of the license.

syntax highlighting: