Article View: es.comp.os.linux.programacion
Article #12338Re: Elegir un fichero al azar
From: rvm
Date: Tue, 31 Jul 2001 17:28
Date: Tue, 31 Jul 2001 17:28
27 lines
1932 bytes
1932 bytes
El Mi� 25 Jul 2001 22:23, Antonio Villalon escribi� lo siguiente: > rvm <rvm@linuxfan.com> wrote: > [...] > : Quisiera saber si es posible en bash leer el nombre de todos los ficheros > : de un directorio (o todos los *.jpg, por ejemplo) y luego seleccionar > : aleatoriamente uno de ellos. Luego ese fichero se lo pasar�a al xloadimage > : para que pusiera la imagen en la pantalla. > > Holas, > Puedes hacer algo parecido a esto (ojo con los valores +/-1, lo mismo se me > ha pasado alguno): > > NFILES=`find . -name "*.jpg"|wc -l` > file=`echo $[$RANDOM%$[NFILES+1]]` El resultado de la l�nea anterior a veces es 0. Parece que as� se soluciona: file=`echo $[$RANDOM%$[NFILES]+1]` Por lo dem�s va estupendamente. Muchas gracias por tu ayuda :-) -- Ricardo Villalba rvmsoft at jazzfree.com http://members.xoom.com/rvmsoft/linux Linux registered user 90754
Technical Details
Message-ID:
<1801209.tDmvXUDI8C@rvmsoft.localdomain>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!newscore.gigabell.net!fu-berlin.de!uni-berlin.de!62-37-2-29.dialup.uni2.ES!not-for-mailReferences:
<2522487.MNUckLgytD@rvmsoft.localdomain> <9jn9rl$igf$1@polaris.cc.upv.es>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,a6a4e55da032ea5d X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2001-08-01 11:02:44 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!newscore.gigabell.net!fu-berlin.de!uni-berlin.de!62-37-2-29.dialup.uni2.ES!not-for-mail From: rvm <rvm@linuxfan.com> Newsgroups: es.comp.os.linux.programacion Subject: Re: Elegir un fichero al azar Date: Tue, 31 Jul 2001 19:28:42 +0200 Lines: 29 Message-ID: <1801209.tDmvXUDI8C@rvmsoft.localdomain> References: <2522487.MNUckLgytD@rvmsoft.localdomain> <9jn9rl$igf$1@polaris.cc.upv.es> NNTP-Posting-Host: 62-37-2-29.dialup.uni2.es (62.37.2.29) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8Bit X-Trace: fu-berlin.de 996688950 3425207 62.37.2.29 (16 [67005]) X-Orig-Path: 127.0.0.1!nobody User-Agent: Fast-KNode/0.4 (http://www.escomposlinux.org/rvm/)