I need to be able to generate a random number between 2013 and 2044 (inclusive). I have tried the two scripts below, but the output is not quite random in either case. Many numbers are repeated, and others missing. Is there a way to get around this?
Here is the first script:
i="1"
x="2014"
y="2044"
while [ $i != 32 ]; do
var=$RANDOM
var=$[ $x + $var % ($y + 1 -$x) ]
echo $var
i=$[$i+1]
done
Here is the second
i="1"
while [ $i != 32 ]; do
var=$(shuf -i 2014-2044 -n1)
echo $var
i=$[$i+1]
done
Thanks, Ciara