[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
$RANDOM is unusable
From: |
Heikki Vesalainen |
Subject: |
$RANDOM is unusable |
Date: |
Thu, 16 Jan 2003 14:08:01 +0200 (EET) |
GNU bash, version 2.04.11(1)-release (i386-redhat-linux-gnu)
Copyright 1999 Free Software Foundation, Inc.
On Pentium III (Coppermine), 794.719, 255928 kB RAM
The $RANDOM is totally unusable if called with some invariable interval.
The below code is meant to produce random numbers between 1-4, but instead
it just produces a string of form i=i+1; where only the initial value of i
is random.
code:
while true; do
sleep 1;
let RND=$RANDOM%4+1
echo $RND
done
output:
4
1
2
3
4
1
2
3
4
1
2
3
4
1
2
3
4
1
2
3
4
1
2
3
4
1
2
3
4
1
2
3
and so on.
Heikki Vesalainen, Mermit
: GSM +358.50.3695362
: vesalainen@mermit.fi
- $RANDOM is unusable,
Heikki Vesalainen <=