nushell/docs/commands/random.md

3.8 KiB

random

Use random to generate random values

bool

  • random bool: Generate a random boolean value

bool Flags

  • -b, --bias <number>: Adjusts the probability of a "true" outcome

bool Examples

> random bool
false
> random bool --bias 0.75
true

dice

  • random dice: Generate a random dice roll

dice Flags

  • d, --dice <integer>: The amount of dice being rolled
  • s, --sides <integer>: The amount of sides a die has

dice Examples

> random dice
4
> random dice -d 10 -s 12
───┬────
 011
 111
 211
 311
 45
 53
 610
 77
 83
 91
───┴────
> random dice --dice 1024 --sides 16 | histogram | sort-by count
────┬───────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
 #  │ value │ count │ frequency
────┼───────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
  01454 │ **********************************************************************
  1455 │ ***********************************************************************
  21058 │ ***************************************************************************
  31559 │ ****************************************************************************
  41160 │ *****************************************************************************
  5760 │ *****************************************************************************
  61661 │ *******************************************************************************
  7562 │ ********************************************************************************
  8363 │ *********************************************************************************
  9963 │ *********************************************************************************
 10264 │ ***********************************************************************************
 11868 │ ****************************************************************************************
 12171 │ ********************************************************************************************
 131373 │ **********************************************************************************************
 14676 │ **************************************************************************************************
 151277 │ ****************************************************************************************************
────┴───────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────

uuid

  • random uuid: Generate a random uuid4 string

uuid Examples

> random uuid
8af4de39-acbc-42f0-94d1-7cfad6c01f8b