# Output 1 random value between 1 and 100
shuf --random-source='/dev/urandom' -n 1 -i 1-100;
# 57
By default these commands use an internal pseudo-random generator initialized by a small amount of entropy, but can be directed to use an external source with the --random-source=file
--random-source=fileoption. An error is reported if file does not contain enough bytes. For example, the device file/dev/urandom...
Source: https://www.gnu.org/software/coreutils/manual/html_node/Random-sources.html
Some examples:
shuf --random-source='/dev/urandom' -n 100 -i 1-5 | perl -pe 's/\n/ /g;';
# 2 1 5 4 3
shuf --random-source='/dev/urandom' -n 1 -i 1-18446744073709551615;
# 3784824711059790616
shuf --random-source='/dev/urandom' -n 1 -i 1-18446744073709551616;
# shuf: invalid input range: ‘18446744073709551616’: Value too large for defined data type
shuf --random-source='/dev/urandom' -n 1 -i 0-18446744073709551615;
# shuf: invalid input range: ‘0-18446744073709551615’
shuf --random-source='/dev/urandom' -i 1-18446744073709551615;
# shuf: memory exhausted
It's worth to state the following:
shuf -i 2-0; echo $?;
# shuf: invalid input range: ‘2-0’
# 1
shuf -i 1-0; echo $?;
# 0
Related: https://news.ycombinator.com/item?id=14846285 (Careful, shuf is not cryptographically safe by default...)