[gull] ls au hasard
Cédric Bouvier
cbouvi at free.fr
Tue Jan 24 10:23:09 CET 2006
Le mardi 24 janvier 2006, à 08 heures 56, Julien Künzi écrivait :
> On Saturday 21 January 2006 16:34, François Heredero - Top Music SA wrote:
> > [snip]
> > 2) Mélanger au hasard les lignes d'un fichier
> > [moi at ici dossier]# melange resultat_ls
> > dossier1/dossier2/fichier2_1.mp3
> > fichier1.mp3
> > dossier1/fichier1_1.mp3
> > dossier1/fichier1_2.mp3
> > fichier2.mp3
>
> Je ferais ça en Perl.
>
> julien at hello:/tmp$ cat resultat_ls | perl -e 'my @in = <STDIN>; while (
> scalar @in ) { print splice @in, int rand scalar @in, 1; }'
> ./libgii0/env.txt
> ./texmf/generic/babel/announce.txt
> ./libwxgtk2.4-python/README.txt
> ./openssl/doc/HOWTO/keys.txt
> ...
Plus simple:
find -iname \*.mp3 | perl -MList::Util=shuffle -e 'print shuffle <>'
List::Util est en standard dans la distribution de Perl depuis la
version 5.7.3.
--
C é d r i c B o u v i e r
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://forum.linux-gull.ch/pipermail/gull/attachments/20060124/34edc5a3/attachment.pgp>
More information about the gull
mailing list