fortune(1)
Display a random, often humorous quotation or saying from a database of fortunes.
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
| Flag | What it does |
|---|---|
-a | Choose from all available fortunes, including offensive ones (default behavior) |
-o | Select only offensive fortunes (mutually exclusive with -a) |
-e | Make fortune selections equal in probability (accounts for file sizes) |
-m PATTERN | Display only fortunes matching the regex PATTERN |
-n LENGTH | Display only fortunes shorter than LENGTH characters |
-s | Display only short fortunes (less than 160 characters) |
-l | Display only long fortunes (more than 160 characters) |
-i | Make regex matching case-insensitive when used with -m |
-f | Print the path of the database file being used and exit |
-w | Wait before printing; pause between fortune printing (for continuous display) |
Examples
Display a random fortune from the default database
fortuneShow only short fortunes (less than 160 characters)
fortune -sDisplay 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 100Get a fortune from the 'fortunes' database file specifically
fortune fortunesPrint the path to the active fortune database file
fortune -fPrint a label followed by a random fortune
echo 'Today: ' && fortune