LinuxCommandLibrary

roll

Generate random numbers within specified ranges

TLDR

Roll 3 6-sided dice and sums the results

$ roll [3d]
copy

Roll 1 8-sided die, add 3 and sum the results
$ roll [d8 + 3]
copy

Roll 4 6-sided dice, keep the 3 highest results and sum the results
$ roll [4d6h3]
copy

Roll 2 12-sided dice 2 times and show every roll
$ roll --verbose [2{2d12]}
copy

Roll 2 20-sided dice until the result is bigger than 10
$ roll "[2d20>10]"
copy

Roll 2 5-sided dice 3 times and show the total sum
$ roll --sum-series [3{2d5]}
copy

SYNOPSIS

roll [-s] [-n] [expression ...]

PARAMETERS

expression
    One or more dice specifications (e.g., 2d6, d20). Defaults to 1d6 if none provided.

-s
    Output only the sum for each expression, suppressing individual die rolls.

-n
    Suppress the grand total output, showing only individual or summed expression results.

DESCRIPTION

The roll command, part of the bsdgames package, simulates rolling various types of dice. Users define dice using AdX (e.g., 2d6 for two 6-sided dice) or X (e.g., d20 for a 20-sided die). If no expression is given, it defaults to 1d6. It's commonly used in role-playing games or for simple random number generation, providing individual roll results and a total sum. Options allow for customization of output, such as showing only sums or suppressing the grand total. It's an entertainment utility, not a core system tool.

CAVEATS

The roll command is typically bundled with the bsdgames package and might require explicit installation on some Linux distributions. It functions primarily as an entertainment or recreational utility, rather than a fundamental system administration or programming tool.

DICE EXPRESSION FORMAT

Dice expressions follow the format AdX, where A is the number of dice (defaults to 1) and X is the number of sides on each die (defaults to 6). For example, 3d8 means three 8-sided dice. A shorthand X (e.g., d20) is equivalent to 1dX.

HISTORY

Originating from the traditional BSD Unix systems, the roll command is a long-standing component of the bsdgames collection. These classic games and recreational utilities were included for user enjoyment and have since been ported to various Linux distributions as optional packages.

SEE ALSO

dice(6)

Copied to clipboard