Fortune (program)
Encyclopedia
fortune is a simple program that displays a pseudorandom message from a database of quotations that first appeared in Version 7 Unix
Version 7 Unix
Seventh Edition Unix, also called Version 7 Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commercialization of Unix by AT&T in the early 1980s...

. The most common version on modern systems is the BSD
Berkeley Software Distribution
Berkeley Software Distribution is a Unix operating system derivative developed and distributed by the Computer Systems Research Group of the University of California, Berkeley, from 1977 to 1995...

 fortune, originally written by Ken Arnold
Ken Arnold
Kenneth Cutts Richard Cabot Arnold is an American computer programmer well known as one of the developers of the 1980s dungeon-crawling computer game Rogue, for his contributions to the original Berkeley distribution of Unix, for his books and articles about C and C++ Kenneth Cutts Richard Cabot ...

. Distributions of fortune are usually bundled with a collection of themed files, containing sayings like those found on fortune cookie
Fortune cookie
A fortune cookie is a crisp cookie usually made from flour, sugar, vanilla, and oil with a "fortune" wrapped inside. A "fortune" is a piece of paper with words of faux wisdom or a vague prophecy...

s (hence the name), quotations from famous people, jokes, or poetry.

fortune is predominantly found on Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 systems, but clients for other platforms also exist. Often, users on text-mode Unix terminals will place this command into either their .profile or .logout files to display them at logon and logout, respectively. It is also used to generate text input for certain XScreenSaver
XScreenSaver
XScreenSaver is a collection of about two hundred free screensavers for Unix and Mac OS X computers. It was created by Jamie Zawinski in 1992 and is still maintained by him....

 modes.

Content

Most Linux systems use a roughly equivalent set of fortune. The fortunes dispensed are slanted heavily toward the user base of Unix, and thus contain many obscure jokes about computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...

 and computer programming
Computer programming
Computer programming is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages. The purpose of programming is to create a program that performs specific operations or exhibits a...

. Other favoured sources include quotations from science fiction
Science fiction
Science fiction is a genre of fiction dealing with imaginary but more or less plausible content such as future settings, futuristic science and technology, space travel, aliens, and paranormal abilities...

 (Star Trek
Star Trek
Star Trek is an American science fiction entertainment franchise created by Gene Roddenberry. The core of Star Trek is its six television series: The Original Series, The Animated Series, The Next Generation, Deep Space Nine, Voyager, and Enterprise...

, The Cyberiad
The Cyberiad
The Cyberiad is a series of humorous short stories by Stanisław Lem. The Polish version was first published in 1965, with an English translation appearing in 1974. The main protagonists of the series are Trurl and Klapaucius, the "constructors"....

, Doctor Who
Doctor Who
Doctor Who is a British science fiction television programme produced by the BBC. The programme depicts the adventures of a time-travelling humanoid alien known as the Doctor who explores the universe in a sentient time machine called the TARDIS that flies through time and space, whose exterior...

, The Hitchhiker's Guide to the Galaxy
The Hitchhiker's Guide to the Galaxy
The Hitchhiker's Guide to the Galaxy is a science fiction comedy series created by Douglas Adams. Originally a radio comedy broadcast on BBC Radio 4 in 1978, it was later adapted to other formats, and over several years it gradually became an international multi-media phenomenon...

, etc.), Zippy the Pinhead
Zippy the Pinhead
Zippy is an American comic strip created by Bill Griffith. The character of Zippy the Pinhead initially appeared in underground publications during the 1970s...

, and the writings of Ambrose Bierce
Ambrose Bierce
Ambrose Gwinnett Bierce was an American editorialist, journalist, short story writer, fabulist and satirist...

 and Dave Barry
Dave Barry
David "Dave" Barry is a Pulitzer Prize-winning American author and columnist, who wrote a nationally syndicated humor column for The Miami Herald from 1983 to 2005. He has also written numerous books of humor and parody, as well as comedic novels.-Biography:Barry was born in Armonk, New York,...

. Most fortune collections also include a wide variety of more conventionally-sourced quotations, jokes, and other short passages. A few distributions include so-called "offensive" dicta, which require the -a or -o options to be passed for viewing.

Purpose

One of the included fortunes, from the "goedel" collection of fortunes about fortune itself, sums up the purpose of the program:

Has anyone realized that the purpose of the fortune cookie program is to
defuse project tensions? When did you ever see a cheerful cookie, a
non-cynical, or even an informative cookie?
Perhaps inadvertently, we have a channel for our aggressions. This
still begs the question of whether the cookie releases the pressure or only
serves to blunt the warning signs.

Long live the revolution!
Have a nice day.

Fortune files

Conventional versions of fortune use two files for each quotation list: a text file with quotations, each separated by the character "%" on its own line, and a random-access data file generated by the strfile(8) program. Alternative implementations, including those made for display on Web pages, typically use only the text file.

Common options

Several common options exist that change the way command-line versions of fortune behave:
Option Action
-a Choose from all databases, regardless of whether they are considered "offensive"
-e Make the probability of choosing a fortune file equal to that of all other files
-f Print out a list of all fortune files that would have been searched, but do not print a fortune
-i When used with -m, make regular expression searching case-insensitive
-l Use only quotations longer than the length specified with -n, or 160 characters if -n is not used
-m [pattern] Print all fortunes matching the regular expression
Regular expression
In computing, a regular expression provides a concise and flexible means for "matching" strings of text, such as particular characters, words, or patterns of characters. Abbreviations for "regular expression" include "regex" and "regexp"...

specified in [pattern]
-n [length] Override the length used by -l and -s to determine "long" and "short" messages (default 160 characters)
-o Choose only from "offensive" databases
-s Use only quotations shorter than the length specified with -n, or 160 characters if -n is not used
-w Wait for a period of time before terminating; useful for situations in which a fortune needs to be read before the screen is cleared

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK