variable
Bash RANDOM — pseudorandom integer
Each reference generates an integer from 0 to 32767. Assignment seeds the generator. Sequences may differ with compatibility level and subshell state. Not suitable for secrets or cryptographic tokens. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): in range.
Formal Syntax & Structure
bash syntaxbash
${RANDOM}Return Value
integer
An integer in the inclusive range 0–32767.
Working Example
Example Snippetbash
n=$RANDOM(( n >= 0 && n <= 32767 )) || exit 1printf 'in range\n'