You are not logged in.
I have a trouble getting bash to generate random numbers. I would like to make a function that would generate random numbers belonging to a certain range, like for example 300-1000. I have got this far with my function:
function rnumber()
{
#returns a random number between $1 and $2
#parameters:
#$1: floor
#$2: range
let fin=$2-$1+1
return $((RANDOM%$fin+$1))
}
Now with smaller numbers like 0-100 it works perfectly, but for some reason fails on big numbers - like 200-400.
Offline
The largest return value is 255.
echo the value instead of returning it, then use backquotes or $() to set the output to a variable.
Offline
Thanks! That was it
Offline