It's simple to call a number between two numbers
echo $( shuf -i 15-16 -n 1 )
or call two numbers using variables
#!/bin/bash
var1=15
var2=16
echo "${var1}${var2}"
exit ;
sh
Question - is it possible to call number 15 (or $var1 from second example) - 4 times more often than number 16 (or $var2 from second example) ?
Ask shuf
for a single value and provide it with input data that contains four times as many 15
than 16
. In bash
,
shuf -n 1 <<<$'15\n15\n15\n15\n16'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.