From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18505 invoked by alias); 11 Mar 2011 22:42:38 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15869 Received: (qmail 20417 invoked from network); 11 Mar 2011 22:42:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at myproxylists.com designates 217.119.39.74 as permitted sender) X-Originating-IP: 127.0.0.1 Message-ID: Date: Sat, 12 Mar 2011 00:42:32 +0200 Subject: A few rand48() example for the list From: nix@myproxylists.com To: zsh-users@zsh.org User-Agent: SquirrelMail/1.4.20 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Hi. I remember asking earlier for rand48() related but could not get a working solution. Afterwards I found it on my own. Here are a few handy solutions. Random password using rand48(): zmodload -i zsh/mathfunc length=8 # Max possible value are equal to size of $chars. chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?:^~@#$%&*_+=[]/" while (( i++ < length )) do random=$((1 + int(${(c)#chars} * rand48()))) password+="$chars[$random]" chars[$random]="" done print "$password" Random word from a string using rand48(): zmodload -i zsh/mathfunc words="NIX Linux ZSH BASH PHP" word=$((1 + int(${(w)#words} * rand48()))) print ${${words[*]}[(w)$word]} --- The ran48()is significantly more random than bash/zsh $RANDOM built-in Regards NiX