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 -->
  #2 (permalink)  
Old 11-25-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,289
Pipe the numbers into sort & uniq. You will get than less since the duplicates will be deleted, but maybe you have another loop checking the count of numbers and generate some more. Maybe there is already some nice random function in Perl.

Also these lines
Quote:
number=$[ [$RANDOM % 20 ] + 1 ]
"echo $number"
did not work for me. I had to change them to

Code:
number=$(( ( $RANDOM % 20 ) + 1 ))
echo "$number"

The 1st line could be because of your shell, but the " in front of the echo seems to be a typo.

Also please use [ code ] and [ /code ] tags to make your code better visible; I edited your post to show what I mean, look for the blue background of your code.

Last edited by zaxxon; 11-25-2008 at 02:24 AM..