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 -o Choose only from potentially offensive aphorisms. The -o option
85 is ignored if a fortune directory is specified.
86
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 -s Short apothegms only. See -n on which fortunes are considered
101 “short”.
102
103
104 -i
105
106 Ignore case for -m patterns.
107
108
109 -w
110
111 Wait before termination for an amount of time calculated from the
112 number of characters in the message. This is useful if it is
113 executed as part of the logout procedure to guarantee that the
114 message can be read before the screen is cleared.
115
116
117
118 The user may specify alternate sayings. You can specify a specific
119 file, a directory which contains one or more files, or the special word
120 all which says to use all the standard databases. Any of these may be
121 preceded by a percentage, which is a number n between 0 and 100
122 inclusive, followed by a %. If it is, there will be a n percent
123 probability that an adage will be picked from that file or directory.
124 If the percentages do not sum to 100, and there are specifications
125 without percentages, the remaining percent will apply to those files
126 and/or directories, in which case the probability of selecting from one
127 of them will be based on their relative sizes.
128
129
130 As an example, given two databases funny and not-funny, with funny
131 twice as big (in number of fortunes, not raw file size), saying
132
133
134 fortune funny not-funny
135
136
137 will get you fortunes out of funny two-thirds of the time. The command
138
139
140 fortune 90% funny 10% not-funny
141
142
143 will pick out 90% of its fortunes from funny (the “10% not-funny” is
144 unnecessary, since 10% is all that's left).
145
146
147 The -e option says to consider all files equal; thus
148
149
150 fortune -e funny not-funny
151
152
153 is equivalent to
154
155
156 fortune 50% funny 50% not-funny
157
158
159 This fortune also supports the BSD method of appending “-o” to database
160 names to specify offensive fortunes. However this is not how fortune
161 stores them: offensive fortunes are stored in a separate directory
162 without the “-o” infix. A plain name (i.e., not a path to a file or
163 directory) that ends in “-o” will be assumed to be an offensive
164 database, and will have its suffix stripped off and be searched in the
165 offensive directory (even if the neither of the -a or -o options were
166 specified). This feature is not only for backwards-compatibility, but
167 also to allow users to distinguish between inoffensive and offensive
168 databases of the same name.
169
170
171 For example, assuming there is a database named definitions in both the
172 inoffensive and potentially offensive collections, then the following
173 command will select an inoffensive definition 90% of the time, and a
174 potentially offensive definition for the remaining 10%:
175
176
177 fortune 90% definitions definitions-o
178
179
181 Note: these are the defaults as defined at compile time.
182
183
184 /usr/share/games/fortune Directory for innoffensive fortunes.
185
186
187 /usr/share/games/fortune/off Directory for offensive fortunes.
188
189
190 If a particular set of fortunes is particularly unwanted, there is an
191 easy solution: delete the associated .dat file. This leaves the data
192 intact, should the file later be wanted, but since fortune no longer
193 finds the pointers file, it ignores the text file.
194
195
197 The division of fortunes into offensive and non-offensive by directory,
198 rather than via the `-o' file infix, is not 100% compatible with
199 original BSD fortune. Although the `-o' infix is recognised as
200 referring to an offensive database, the offensive database files still
201 need to be in a separate directory. The workaround, of course, is to
202 move the `-o' files into the offensive directory (with or without
203 renaming), and to use the -a option.
204
205
206 The supplied fortune databases have been attacked, in order to correct
207 orthographical and grammatical errors, and particularly to reduce
208 redundancy and repetition and redundancy. But especially to avoid
209 repetitiousness. This has not been a complete success. In the process,
210 some fortunes may also have been lost.
211
212
213 The fortune databases are now divided into a larger number of smaller
214 files, some organized by format (poetry, definitions), and some by
215 content (religion, politics). There are parallel files in the main
216 directory and in the offensive files directory (e.g.,
217 fortunes/definitions and fortunes/off/definitions). Not all the
218 potentially offensive fortunes are in the offensive fortunes files, nor
219 are all the fortunes in the offensive files potentially offensive,
220 probably, though a strong attempt has been made to achieve greater
221 consistency. Also, a better division might be made.
222
223
225 This version of fortune is based on the NetBSD fortune 1.4, but with a
226 number of bug fixes and enhancements.
227
228
229 The original fortune/strfile format used a single file; strfile read
230 the text file and converted it to null-delimited strings, which were
231 stored after the table of pointers in the .dat file. By NetBSD fortune
232 1.4, this had changed to two separate files: the .dat file was only the
233 header (the table of pointers, plus flags; see strfile.h), and the text
234 strings were left in their own file. The potential problem with this is
235 that text file and header file may get out of synch, but the advantage
236 is that the text files can be easily edited without resorting to unstr,
237 and there is a potential savings in disk space (on the assumption that
238 the sysadmin kept both .dat file with strings and the text file).
239
240
241 Many of the enhancements made over the NetBSD version assumed a Linux
242 system, and thus caused it to fail under other platforms, including
243 BSD. The source code has since been made more generic, and currently
244 works on SunOS 4.x as well as Linux, with support for more platforms
245 expected in the future. Note that some bugs were inadvertently
246 discovered and fixed during this process.
247
248
249 At a guess, a great many people have worked on this program, many
250 without leaving attributions.
251
252
254 re_comp(3), regcomp(3), strfile(1), unstr(1)
255
256
257
258
259BSD Experimental 19 April 94 [May. 97] FORTUNE(6)