<p>@j23 has given a very reasonable operational answer.  By way of possible explanation of the behaviour you observed, the number you are printing is not a single <code>$RANDOM</code> value, but the product of two such values.  Pairs of consecutive outputs of a pseudorandom number generator (PRNG) are not necessarily as independent as you might like.  E.g., Matlab <code>randn</code> had a correlation problem in 2006 (arXiv:math/0603058).</p>
Duplicate numbers using $RANDOM in Bash
<p>I wrote a script with bash in while loop. The code:</p>

<pre><code>number=0
while [ 1500 -gt $number ]
do
  var="abcdefghijklmnopqrstuvxyz"
  letter1="${var:$(( RANDOM % ${#var} )):1}"
  letter2="${var:$(( RANDOM % ${#var} )):1}"
  a=$RANDOM
  b=$RANDOM
  c=$(( $a * $b))
  echo "$letter1$letter2 $c" &gt;&gt; a.txt
  number=$(( 1 + $number ))
done
</code></pre>

<p>but now I see duplicate numbers in result:</p>

<pre><code>Result:
ab 15474
at 15474
yh 15474
gd 15474
re 18696
jg 18696
</code></pre>

<p>The numbers are duplicate.</p>

<p>I guess the <code>$RANDOM</code> changes after a invariant time and my script starts again the the <code>while</code> loop faster than the <code>$RANDOM</code> changes.</p>

<p>Can you help me an other randomization way?</p>