Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
random number tip
- X-seq: zsh-users 12106
- From: Atom Smasher <atom@xxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: random number tip
- Date: Thu, 25 Oct 2007 17:18:38 +1300 (NZDT)
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Openpgp: id=0xB88D52E4D9F57808; algo=1 (RSA); size=4096; url=http://atom.smasher.org/pgp.txt
here's one for the archives...
somewhere (???) i saw a zsh tip for getting random numbers in the range of
x-y:
$[${RANDOM}%1000] # random between 0-999
$[${RANDOM}%11+10] # random between 10-20
but if you need a random number that's N digits long (3 digits, in this
example):
${(l:3::0:)${RANDOM}}
--
...atom
________________________
http://atom.smasher.org/
762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
-------------------------------------------------
"We will, in fact, be greeted as liberators."
-- Dick Cheney, 16 March 2003
Messages sorted by:
Reverse Date,
Date,
Thread,
Author