random numbers in a C shell script?

Ubben Greg bink at aplcen.apl.jhu.edu
Wed May 17 13:18:04 AEST 1989


In article <540 at lakart.UUCP> dg at lakart.UUCP (David Goodenough) writes:
> ...
> @ rng = `date | tr : ' ' | awk '{ print $3 * $4 * $5 * $6}'` + $$
> ...

Not being qualified to play with the algorithm, I present instead
another way of doing the SAME thing (in Bourne shell):
	rng=`date +"%d %H*%M*%S*$$+p" | dc`
You'll probably want to throw in a MOD too.

Another idea:
	combine in the output of a TIME or TIMEX (something like
	"timex date 2>&1 | sed ... | dc")

Also, I'm not good at csh, but can't you just command substitute a
date +"..." right into the @ instead of making awk do the math?
Something like
	@ rng = `date +"%d * %H * %M * %S"` + $$
maybe with an EVAL thrown in for good measure?

						-- Greg Ubben
						   bink at aplcen.apl.jhu.edu



More information about the Comp.unix.questions mailing list