{
    "mode": "man",
    "parameter": "fortune",
    "section": "6",
    "url": "https://www.chedong.com/phpMan.php/man/fortune/6/json",
    "generated": "2026-06-03T08:03:06Z",
    "synopsis": "fortune [-acefilosuw] [-n length] [ -m pattern] [[n%] file/dir/all]",
    "sections": {
        "NAME": {
            "content": "fortune - print a random, hopefully interesting, adage\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "fortune [-acefilosuw] [-n length] [ -m pattern] [[n%] file/dir/all]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "When  fortune  is  run with no arguments it prints out a random epigram. Epigrams are divided\ninto several categories, where each category is sub-divided into those which are  potentially\noffensive and those which are not.\n",
            "subsections": [
                {
                    "name": "Options",
                    "content": "The options are as follows:\n"
                },
                {
                    "name": "-a -o",
                    "content": "information on offensive fortunes.)\n",
                    "flag": "-o"
                },
                {
                    "name": "-c",
                    "content": "",
                    "flag": "-c"
                },
                {
                    "name": "-e",
                    "content": "files).\n",
                    "flag": "-e"
                },
                {
                    "name": "-f",
                    "content": "",
                    "flag": "-f"
                },
                {
                    "name": "-l -n",
                    "content": "",
                    "flag": "-n"
                },
                {
                    "name": "-m",
                    "content": "Print  out  all fortunes which match the basic regular expression pattern.  The syntax\nof these expressions depends on how your system defines recomp(3) or regcomp(3),  but\nit should nevertheless be similar to the syntax used in grep(1).\n\nThe  fortunes  are  output  to standard output, while the names of the file from which\neach fortune comes are printed to standard error.  Either or both can  be  redirected;\nif  standard  output  is redirected to a file, the result is a valid fortunes database\nfile.  If standard error is also redirected to this file, the result is  still  valid,\nbut  there  will be ``bogus'' fortunes, i.e. the filenames themselves, in parentheses.\nThis can be useful if you wish to remove the  gathered  matches  from  their  original\nfiles, since each filename-record will precede the records from the file it names.\n",
                    "flag": "-m"
                },
                {
                    "name": "-n",
                    "content": "Set the longest fortune length (in characters) considered to be ``short'' (the default\nis 160).  All fortunes longer than this are considered ``long''.  Be careful!  If  you\nset  the  length  too  short  and ask for short fortunes, or too long and ask for long\nones, fortune goes into a never-ending thrash loop.\n",
                    "flag": "-n"
                },
                {
                    "name": "-o",
                    "content": "tune directory is specified.\n\nPlease,  please, please request a potentially offensive fortune if and only if you be‐‐\nlieve, deep in your heart, that you are willing to be offended. (And that you'll  just\nquit using -o rather than give us grief about it, okay?)\n\n...  let  us  keep in mind the basic governing philosophy of The Brotherhood, as hand‐\nsomely summarized in these words: we believe in healthy, hearty laughter -- at the ex‐\npense of the whole human race, if needs be.  Needs be.\n--H. Allen Smith, \"Rude Jokes\"\n",
                    "flag": "-o"
                },
                {
                    "name": "-s -n",
                    "content": "",
                    "flag": "-n"
                },
                {
                    "name": "-i",
                    "content": "",
                    "flag": "-i"
                },
                {
                    "name": "-w",
                    "content": "in the message.  This is useful if it is executed as part of the logout  procedure  to\nguarantee that the message can be read before the screen is cleared.\n",
                    "flag": "-w"
                },
                {
                    "name": "-u",
                    "content": "The  user  may specify alternate sayings.  You can specify a specific file, a directory which\ncontains one or more files, or the special word all which says to use all the standard  data‐\nbases.   Any  of these may be preceded by a percentage, which is a number n between 0 and 100\ninclusive, followed by a %.  If it is, there will be a n percent probability  that  an  adage\nwill  be  picked from that file or directory. If the percentages do not sum to 100, and there\nare specifications without percentages, the remaining  percent  will  apply  to  those  files\nand/or directories, in which case the probability of selecting from one of them will be based\non their relative sizes.\n\nAs an example, given two databases funny and not-funny, with funny twice as big (in number of\nfortunes, not raw file size), saying\n\nfortune funny not-funny\n\nwill get you fortunes out of funny two-thirds of the time.  The command\n\nfortune 90% funny 10% not-funny\n\nwill pick out 90% of its fortunes from funny (the ``10% not-funny'' is unnecessary, since 10%\nis all that's left).\n\nThe -e option says to consider all files equal; thus\n\nfortune -e funny not-funny\n\nis equivalent to\n\nfortune 50% funny 50% not-funny\n\n",
                    "flag": "-u"
                }
            ]
        },
        "FILES": {
            "content": "Note: these are the defaults as defined at compile time.\n\n/usr/share/games/fortunes\nDirectory for innoffensive fortunes.\n/usr/share/games/fortunes/off\nDirectory for offensive fortunes.\n\nIf a particular set of fortunes is particularly unwanted, there is an easy  solution:  delete\nthe  associated .dat file.  This leaves the data intact, should the file later be wanted, but\nsince fortune no longer finds the pointers file, it ignores the text file.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "The supplied fortune databases have been attacked, in order  to  correct  orthographical  and\ngrammatical errors, and particularly to reduce redundancy and repetition and redundancy.  But\nespecially to avoid repetitiousness.  This has not been a complete success.  In the  process,\nsome fortunes may also have been lost.\n\nThe  fortune  databases are now divided into a larger number of smaller files, some organized\nby format (poetry, definitions), and some by content (religion, politics).  There are  paral‐\nlel  files in the main directory and in the offensive files directory (e.g., fortunes/defini‐\ntions and fortunes/off/definitions).  Not all the potentially offensive fortunes are  in  the\noffensive  fortunes files, nor are all the fortunes in the offensive files potentially offen‐\nsive, probably, though a strong attempt has been made to achieve greater consistency.   Also,\na better division might be made.\n\nWhen passing files to fortune, directories must be specified by absolute pathnames, and file‐\nnames  starting  with  a  dot   are   ignored.   See:   http://bugs.debian.org/cgi-bin/bugre‐\nport.cgi?bug=241888\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "This  version  of  fortune is based on the NetBSD fortune 1.4, but with a number of bug fixes\nand enhancements.\n\nThe original fortune/strfile format used a single file; strfile read the text file  and  con‐\nverted  it  to  null-delimited  strings, which were stored after the table of pointers in the\n.dat file.  By NetBSD fortune 1.4, this had changed to two separate files: the .dat file  was\nonly the header (the table of pointers, plus flags; see strfile.h), and the text strings were\nleft in their own file.  The potential problem with this is that text file  and  header  file\nmay  get  out of synch, but the advantage is that the text files can be easily edited without\nresorting to unstr, and there is a potential savings in disk space (on  the  assumption  that\nthe sysadmin kept both .dat file with strings and the text file).\n\nMany of the enhancements made over the NetBSD version assumed a Linux system, and thus caused\nit to fail under other platforms, including BSD.  The source code has since  been  made  more\ngeneric,  and  currently works on SunOS 4.x as well as Linux, with support for more platforms\nexpected in the future.  Note that some bugs were inadvertently discovered and  fixed  during\nthis process.\n\nAt  a  guess,  a great many people have worked on this program, many without leaving attribu‐\ntions.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "recomp(3), regcomp(3), strfile(1), unstr(1)\n\n\n\nBSD Experimental                        19 April 94 [May. 97]                             FORTUNE(6)",
            "subsections": []
        }
    },
    "summary": "fortune - print a random, hopefully interesting, adage",
    "flags": [
        {
            "flag": "-o",
            "long": null,
            "arg": null,
            "description": "information on offensive fortunes.)"
        },
        {
            "flag": "-c",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-e",
            "long": null,
            "arg": null,
            "description": "files)."
        },
        {
            "flag": "-f",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-n",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-m",
            "long": null,
            "arg": null,
            "description": "Print out all fortunes which match the basic regular expression pattern. The syntax of these expressions depends on how your system defines recomp(3) or regcomp(3), but it should nevertheless be similar to the syntax used in grep(1). The fortunes are output to standard output, while the names of the file from which each fortune comes are printed to standard error. Either or both can be redirected; if standard output is redirected to a file, the result is a valid fortunes database file. If standard error is also redirected to this file, the result is still valid, but there will be ``bogus'' fortunes, i.e. the filenames themselves, in parentheses. This can be useful if you wish to remove the gathered matches from their original files, since each filename-record will precede the records from the file it names."
        },
        {
            "flag": "-n",
            "long": null,
            "arg": null,
            "description": "Set the longest fortune length (in characters) considered to be ``short'' (the default is 160). All fortunes longer than this are considered ``long''. Be careful! If you set the length too short and ask for short fortunes, or too long and ask for long ones, fortune goes into a never-ending thrash loop."
        },
        {
            "flag": "-o",
            "long": null,
            "arg": null,
            "description": "tune directory is specified. Please, please, please request a potentially offensive fortune if and only if you be‐‐ lieve, deep in your heart, that you are willing to be offended. (And that 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 hand‐ somely summarized in these words: we believe in healthy, hearty laughter -- at the ex‐ pense of the whole human race, if needs be. Needs be. --H. Allen Smith, \"Rude Jokes\""
        },
        {
            "flag": "-n",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-i",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-w",
            "long": null,
            "arg": null,
            "description": "in the message. This is useful if it is executed as part of the logout procedure to guarantee that the message can be read before the screen is cleared."
        },
        {
            "flag": "-u",
            "long": null,
            "arg": null,
            "description": "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 data‐ bases. Any of these may be preceded 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 remaining 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 (in number of fortunes, not raw file size), 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 consider all files equal; thus fortune -e funny not-funny is equivalent to fortune 50% funny 50% not-funny"
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "recomp",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/recomp/3/json"
        },
        {
            "name": "regcomp",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/regcomp/3/json"
        },
        {
            "name": "strfile",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/strfile/1/json"
        },
        {
            "name": "unstr",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/unstr/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Print a random quotation (fortune-cookie style).",
        "examples": [
            {
                "description": "Print a quotation",
                "command": "fortune"
            },
            {
                "description": "Print an [o]ffensive quotation",
                "command": "fortune -o"
            },
            {
                "description": "Print a [l]ong quotation",
                "command": "fortune -l"
            },
            {
                "description": "Print a [s]hort quotation",
                "command": "fortune -s"
            },
            {
                "description": "List the available quotation database [f]iles",
                "command": "fortune -f"
            },
            {
                "description": "Print a quotation from one of the database files listed by `fortune -f`",
                "command": "fortune {{path/to/file}}"
            },
            {
                "description": "Pipe a fortune through another command (like `cowsay` or `lolcat`)",
                "command": "fortune | cowsay | lolcat"
            }
        ]
    }
}