The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 07:23 AM
A few questions... halluc1nati0n UNIX for Dummies Questions & Answers 2 03-28-2007 10:29 AM
3 questions in 1 alikun UNIX for Dummies Questions & Answers 2 03-27-2007 02:59 AM
ftp questions lewisoco UNIX for Advanced & Expert Users 5 10-27-2005 05:45 PM
questions tamemi UNIX for Dummies Questions & Answers 1 08-17-2003 09:28 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-28-2007
gina gina is offline
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
  #2 (permalink)  
Old 05-28-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,932
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
  #3 (permalink)  
Old 05-28-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,425
you can also use rand() from awk
Code:
#num=$(awk 'BEGIN{srand();print int(6*rand())+1}')
#echo $num
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:40 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0