$linuxjunkies
>

fortune(1)

Display a random, often humorous quotation or saying from a database of fortunes.

UbuntuDebianFedoraArch

Synopsis

fortune [OPTION]... [FILE|DIR]...

Description

fortune prints a random epigram, quotation, joke, or saying from its database of text files. By default it searches the system fortune database, typically located in /usr/share/games/fortune/. Each fortune is separated by a % character on its own line.

fortune can be used interactively or in scripts to display random messages. It's commonly used in login shells (.bashrc, .zshrc) to display a quote on startup, or in system messages and status displays.

Common options

FlagWhat it does
-aChoose from all available fortunes, including offensive ones (default behavior)
-oSelect only offensive fortunes (mutually exclusive with -a)
-eMake fortune selections equal in probability (accounts for file sizes)
-m PATTERNDisplay only fortunes matching the regex PATTERN
-n LENGTHDisplay only fortunes shorter than LENGTH characters
-sDisplay only short fortunes (less than 160 characters)
-lDisplay only long fortunes (more than 160 characters)
-iMake regex matching case-insensitive when used with -m
-fPrint the path of the database file being used and exit
-wWait before printing; pause between fortune printing (for continuous display)

Examples

Display a random fortune from the default database

fortune

Show only short fortunes (less than 160 characters)

fortune -s

Display only fortunes containing the word 'linux'

fortune -m 'linux'

Show fortunes matching 'unix' or 'linux', case-insensitive

fortune -im 'unix|linux'

Display fortunes shorter than 100 characters

fortune -n 100

Get a fortune from the 'fortunes' database file specifically

fortune fortunes

Print the path to the active fortune database file

fortune -f

Print a label followed by a random fortune

echo 'Today: ' && fortune

Related commands