Logo 
Search:

Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

Write a script to generate a random number between 1 and 1000.

  Asked By: John    Date: May 13    Category: Unix / Linux / Ubuntu    Views: 1928
  

Hello, I am new here and to Linux/UNIX I need some help to understand Random numbers all the info I can find for this generates negetive numbers as well as positive numbers. I need it to just be positive integers.

Here is what I need
Write a script to generate a random number between 1 and 1000.
#I am also suppose to include this somehow
#make use of system date (seconds) and % operator.


Here is what I have so far

#! /bin/sh

echo $(( 1+(`od -An -N2 -i /dev/random` )%(1000+1) ))

Share: 

 

No Answers Found. Be the First, To Post Answer.

 




Tagged: