Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: pretty easy thing but too hard for me! (random array element)
- X-seq: zsh-users 11732
- From: Artur Penttinen <arto-p@xxxxx>
- To: frioux@xxxxxxxxx
- Subject: Re: pretty easy thing but too hard for me! (random array element)
- Date: Thu, 02 Aug 2007 01:39:44 +0400
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: 1660000000196252333
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: 1660000000196252333
02.08.07, 01:23, fREW <frioux@xxxxxxxxx>:
> Hello zsh amigos!
> I want to make a tiny fuction that will
> #1 get a list of files
> #2 choose a random file
> #3 open the random file
> I was going to just do something like
> arr=( * )
> and then
> feh $arr[(some random number or something)]
> but I don't know how to do the random number part and there may be a
> better way anyway. Thoughts? Ideas? Wisdom?
$arr[$RANDOM%$#arr+1] ?
--
wbw, artur
Messages sorted by:
Reverse Date,
Date,
Thread,
Author