Random

random_seed

Generate a numeric seed suitable for use with PRNG functions. Prefers /dev/urandom+od, falls back to date +%s, then a portable shell calculation.

Exit codes

  • 0: Always

Output on stdout

  • A large positive integer suitable for use as a PRNG seed

random_lcg

Generate random integers using a BSD-style Linear Congruential Generator. Produces values in the range 0-32767, matching the range of $RANDOM.

Arguments

  • $1 (int): Optional: count of numbers to generate (default: 1)
  • $2 (int): Optional: seed value (default: epoch seconds via random_seed)

Exit codes

  • 0: Always

Output on stdout

  • One random integer per line

random_xorshift128plus

Generate random integers using xorshift128+ with debiased modulo. Selects the word size automatically via getconf LONG_BIT.

Arguments

  • $1 (int): Optional: count of numbers to generate (default: 1)
  • $2 (int): Optional: minimum value (default: 1)
  • $3 (int): Optional: maximum value (default: architecture max)
  • $4 (int): Optional: seed for seed1 (default: random_seed)

Exit codes

  • 0: Always

Output on stdout

  • One random integer per line within [min, max]

random_int

Generate random integers using $RANDOM with debiased modulo.

Arguments

  • $1 (int): Optional: count of numbers to generate (default: 1)
  • $2 (int): Optional: minimum value inclusive (default: 1)
  • $3 (int): Optional: maximum value inclusive (default: 32767)

Exit codes

  • 0: Success
  • 3: min equals max (zero-range)

Output on stdout

  • One random integer per line within [min, max]