Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: pretty easy thing but too hard for me! (random array element)




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