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.

        Cheers,

        Matthew

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: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to