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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Random number in unix scripting 1

Status
Not open for further replies.

spinik

Programmer
Aug 22, 2001
17
0
0
CA
I want to create a random number in a unix script without the use of an extra file. I want to be able to associate this number to a variable and use it later in my script.

I know how to do this in C++ but I want it in my script uniquely.

Can anyone help?
 
Use the RANDOM variable exists on some Unix Shells.
I hope it works...
Unix was made by and for smart people.
 
THis is how I did it for whoever wants it. Trial and error was the solution. RANDOM by itself will not work

RANDOM_NUMBER=`echo | awk '{srand();printf("%6d",100000*rand())}'`
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top