1FORTUNE(6) UNIX Reference Manual FORTUNE(6)
2
3
4
6 fortune - print a random, hopefully interesting, adage
7
8
10
11
12 fortune [-acefilosw]
13 [-n length]
14 [-m pattern]
15 [[n%] file/dir/all]
16
17
19 When fortune is run with no arguments it prints out a random epigram.
20 Epigrams are divided into several categories, where each category is
21 sub-divided into those which are potentially offensive and those which
22 are not.
23
24
25 Options
26 The options are as follows:
27
28
29 -a
30
31 Choose from all lists of maxims, both offensive and not. (See the
32 -o option for more information on offensive fortunes.)
33
34
35 -c
36
37 Show the cookie file from which the fortune came.
38
39
40 -e
41
42 Consider all fortune files to be of equal size (see discussion
43 below on multiple files).
44
45
46 -f
47
48 Print out the list of files which would be searched, but don't
49 print a fortune.
50
51
52 -l
53
54 Long dictums only. See -n on how “long” is defined in this sense.
55
56
57 -m pattern
58
59 Print out all fortunes which match the basic regular expression
60 pattern. The syntax of these expressions depends on how your system
61 defines re_comp(3) or regcomp(3), but it should nevertheless be
62 similar to the syntax used in grep(1).
63
64 The fortunes are output to standard output, while the names of the
65 file from which each fortune comes are printed to standard error.
66 Either or both can be redirected; if standard output is redirected
67 to a file, the result is a valid fortunes database file. If
68 standard error is also redirected to this file, the result is still
69 valid, but there will be “bogus” fortunes, i.e. the filenames
70 themselves, in parentheses. This can be useful if you wish to
71 remove the gathered matches from their original files, since each
72 filename-record will precede the records from the file it names.
73
74
75 -n length
76
77 Set the longest fortune length (in characters) considered to be
78 “short” (the default is 160). All fortunes longer than this are
79 considered “long”. Be careful! If you set the length too short and
80 ask for short fortunes, or too long and ask for long ones, fortune
81 goes into a never-ending thrash loop.
82
83
84
85 -o Choose only from potentially offensive aphorisms. The -o option is
86 ignored if a fortune directory is specified.
87
88 Please, please, please request a potentially offensive fortune if
89 and only if you believe, deep in your heart, that you are willing
90 to be offended. (And that you'll just quit using -o rather than
91 give us grief about it, okay?)
92
93 ... let us keep in mind the basic governing philosophy of The
94 Brotherhood, as handsomely summarized in these words: we believe in
95 healthy, hearty laughter -- at the expense of the whole human race,
96 if needs be. Needs be.
97
98 --H. Allen Smith, "Rude Jokes"
99
100
101
102 -s
103
104 Short apothegms only. See -n on which fortunes are considered
105 “short”.
106
107
108 -i
109
110 Ignore case for -m patterns.
111
112
113 -w
114
115 Wait before termination for an amount of time calculated from the
116 number of characters in the message. This is useful if it is
117 executed as part of the logout procedure to guarantee that the
118 message can be read before the screen is cleared.
119
120
121
122 The user may specify alternate sayings. You can specify a specific
123 file, a directory which contains one or more files, or the special word
124 all which says to use all the standard databases. Any of these may be
125 preceded by a percentage, which is a number n between 0 and 100
126 inclusive, followed by a %. If it is, there will be a n percent
127 probability that an adage will be picked from that file or directory.
128 If the percentages do not sum to 100, and there are specifications
129 without percentages, the remaining percent will apply to those files
130 and/or directories, in which case the probability of selecting from one
131 of them will be based on their relative sizes.
132
133
134 As an example, given two databases funny and not-funny, with funny
135 twice as big (in number of fortunes, not raw file size), saying
136
137
138 fortune funny not-funny
139
140
141 will get you fortunes out of funny two-thirds of the time. The command
142
143
144 fortune 90% funny 10% not-funny
145
146
147 will pick out 90% of its fortunes from funny (the “10% not-funny” is
148 unnecessary, since 10% is all that's left).
149
150
151 The -e option says to consider all files equal; thus
152
153
154 fortune -e funny not-funny
155
156
157 is equivalent to
158
159
160 fortune 50% funny 50% not-funny
161
162
163 This fortune also supports the BSD method of appending “-o” to database
164 names to specify offensive fortunes. However this is not how fortune
165 stores them: offensive fortunes are stored in a separate directory
166 without the “-o” infix. A plain name (i.e., not a path to a file or
167 directory) that ends in “-o” will be assumed to be an offensive
168 database, and will have its suffix stripped off and be searched in the
169 offensive directory (even if the neither of the -a or -o options were
170 specified). This feature is not only for backwards-compatibility, but
171 also to allow users to distinguish between inoffensive and offensive
172 databases of the same name.
173
174
175 For example, assuming there is a database named definitions in both the
176 inoffensive and potentially offensive collections, then the following
177 command will select an inoffensive definition 90% of the time, and a
178 potentially offensive definition for the remaining 10%:
179
180
181 fortune 90% definitions definitions-o
182
183
185 Note: these are the defaults as defined at compile time.
186
187
188 /usr/share/games/fortune Directory for innoffensive fortunes.
189
190
191 /usr/share/games/fortune/off Directory for offensive fortunes.
192
193
194 If a particular set of fortunes is particularly unwanted, there is an
195 easy solution: delete the associated .dat file. This leaves the data
196 intact, should the file later be wanted, but since fortune no longer
197 finds the pointers file, it ignores the text file.
198
199
201 The division of fortunes into offensive and non-offensive by directory,
202 rather than via the `-o' file infix, is not 100% compatible with
203 original BSD fortune. Although the `-o' infix is recognised as
204 referring to an offensive database, the offensive database files still
205 need to be in a separate directory. The workaround, of course, is to
206 move the `-o' files into the offensive directory (with or without
207 renaming), and to use the -a option.
208
209
210 The supplied fortune databases have been attacked, in order to correct
211 orthographical and grammatical errors, and particularly to reduce
212 redundancy and repetition and redundancy. But especially to avoid
213 repetitiousness. This has not been a complete success. In the process,
214 some fortunes may also have been lost.
215
216
217 The fortune databases are now divided into a larger number of smaller
218 files, some organized by format (poetry, definitions), and some by
219 content (religion, politics). There are parallel files in the main
220 directory and in the offensive files directory (e.g.,
221 fortunes/definitions and fortunes/off/definitions). Not all the
222 potentially offensive fortunes are in the offensive fortunes files, nor
223 are all the fortunes in the offensive files potentially offensive,
224 probably, though a strong attempt has been made to achieve greater
225 consistency. Also, a better division might be made.
226
227
229 This version of fortune is based on the NetBSD fortune 1.4, but with a
230 number of bug fixes and enhancements.
231
232
233 The original fortune/strfile format used a single file; strfile read
234 the text file and converted it to null-delimited strings, which were
235 stored after the table of pointers in the .dat file. By NetBSD fortune
236 1.4, this had changed to two separate files: the .dat file was only the
237 header (the table of pointers, plus flags; see strfile.h), and the text
238 strings were left in their own file. The potential problem with this is
239 that text file and header file may get out of synch, but the advantage
240 is that the text files can be easily edited without resorting to unstr,
241 and there is a potential savings in disk space (on the assumption that
242 the sysadmin kept both .dat file with strings and the text file).
243
244
245 Many of the enhancements made over the NetBSD version assumed a Linux
246 system, and thus caused it to fail under other platforms, including
247 BSD. The source code has since been made more generic, and currently
248 works on SunOS 4.x as well as Linux, with support for more platforms
249 expected in the future. Note that some bugs were inadvertently
250 discovered and fixed during this process.
251
252
253 At a guess, a great many people have worked on this program, many
254 without leaving attributions.
255
256
258 re_comp(3), regcomp(3), strfile(1), unstr(1)
259
260
261
262
263BSD Experimental 19 April 94 [May. 97] FORTUNE(6)