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
How to set constrain on random numbers in c ahjiefreak High Level Programming 6 01-11-2008 04:46 AM
how can i isolate the random sequence of numbers using awk? rcon1 UNIX for Dummies Questions & Answers 2 01-09-2008 09:06 AM
generating random numbers with hamming distance 4 hack_tom Shell Programming and Scripting 2 04-29-2007 01:27 AM
genrating pseudo random numbers hack_tom Shell Programming and Scripting 7 04-27-2007 10:10 PM
Random numbers without repetition asal_email UNIX for Dummies Questions & Answers 8 07-14-2005 04:02 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-15-2008
wakhan wakhan is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 58
Random numbers from 0 to 1000

Hello All,

I want to make a simple script which generate random number from 0 to 1000.
and simply display it.

Plz HELP!!!!!!


Regards,
Waqas Ahmed
  #2 (permalink)  
Old 07-15-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
try this:
Code:
#!/bin/ksh
num=$(( $RANDOM % 1001  ))
echo $num

Last edited by jim mcnamara; 07-15-2008 at 07:43 AM..
  #3 (permalink)  
Old 07-15-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
If the RANDOM variable is available:

Code:
printf "%d\n" $(($RANDOM%1000+1))
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 03:49 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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