Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RANDOM in ksh 2

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
PL

how to get random number from 2-4 range?

"because of" zero, it never returns 4:
while true;do echo $(($RANDOM%2+2))|grep 4;done

is it possible to provide the range?
 
Unfortunately, RANDOM is not enabled on our linux servers.
However, my ksh-93 book shows this example:
(dice = (RANDOM % 6) + 1)

==================================
adaptive uber info galaxies (bigger, better, faster than agile big data clouds)


 
What about this ?
$(((RANDOM%3)+2))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top