random numbers in a C shell script?

David Goodenough dg at lakart.UUCP
Tue May 9 00:55:22 AEST 1989


gefuchs at skolem.uucp (Gill E. Fuchs) sez:
> Bon Jorno net,
> 
> how would one go about getting a random numba in a C shell script?
> 
> muchas randomas gracias


#! /bin/csh

@ rng = `date | tr : ' ' | awk '{ print $3 * $4 * $5 * $6}'` + $$

echo $rng

Gives "reasonable" oneshot random numbers. If you need a mess of them,
then take $rng, and a LCG (did I get the term right???):

@rng = $rng * something + something_else

which might keep you happy. Failing this, get on with Knuth Volume 2 and
awk.
-- 
	dg at lakart.UUCP - David Goodenough		+---+
						IHS	| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp at xait.xerox.com		  	  +---+



More information about the Comp.unix.questions mailing list