Running a rand or random script

Matthew Seaman m.seaman at
Mon Jun 16 09:32:47 PDT 2003

On Mon, Jun 16, 2003 at 11:15:17AM -0500, Jack L. Stone wrote:
> I need to run a script, perhaps using FBSD's 'rand' or 'random' command (or
> any other) that will generate one single 5-digit number 'at random' between
> 00001-99999
> Anyone have thoughts on how to do this....??

    perl -e 'printf "%0.5d\n", int(rand(99999) + 1);'

Assuming that range is inclusive.



Nb. Don't use srand() explicitly --- perl will auto-seed the PRNG from
/dev/urandom if left to it's own devices.

Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP:         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url :

More information about the freebsd-questions mailing list