The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
NIM Questions tb0ne AIX 5 08-16-2007 04:23 AM
A few questions... halluc1nati0n UNIX for Dummies Questions & Answers 2 03-28-2007 07:29 AM
3 questions in 1 alikun UNIX for Dummies Questions & Answers 2 03-26-2007 11:59 PM
ftp questions lewisoco UNIX for Advanced & Expert Users 5 10-27-2005 02:45 PM
questions tamemi UNIX for Dummies Questions & Answers 1 08-17-2003 06:28 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-28-2007
Registered User
 

Join Date: May 2007
Posts: 3
Few questions

RANDOM is from 1 - 32767 how can i set it to be from 1 - 6
how can i give every user 100 points at start lets say a game.
within the script if i create users will it by default prevent creating users with same name twice.

I am a beginner in this field and want to do a little game and appreciate any help

Thanks in advance

Gina
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-28-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,472
Take mod of the value which you desire.

for values from 1..x

and if you want reduce the set to 1..y

take mod value for x and y.

Taking mod value with y for value x,

will bring down the set 1..x to 1..y
Reply With Quote
  #3 (permalink)  
Old 05-28-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,441
you can also use rand() from awk
Code:
#num=$(awk 'BEGIN{srand();print int(6*rand())+1}')
#echo $num
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0