The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-25-2008
lalitka lalitka is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 11
Random NUmbers Generation with out repetation

Hi
I have the below code


Code:
 
MAXCOUNT=10
count=1
echo
echo "$MAXCOUNT random numbers:"
echo "-----------------"
while [ "$count" -le $MAXCOUNT ]      # Generate 10 ($MAXCOUNT) random integers.
do
 number=$[ [$RANDOM % 20  ] + 1 ]
    "echo $number"
  let "count += 1"  # Increment count.
done

But aftre executing this

i am getting repetative randiom numbers like ,2,5,6,6,10,8,18,14

but i want unique random numbers ?

can any one help me in solving this ?

Last edited by zaxxon; 11-25-2008 at 02:15 AM.. Reason: codetags implemented