Re: Looping a script

2001-02-19 Thread Bret Hughes
rpjday wrote: > > On Mon, 19 Feb 2001, Bret Hughes wrote: > > > rpjday wrote: > > > > > > actually, if you examine the algorithm, the probability that line n > > > will be chosen as the "new" random line as you read through the file > > > is precisely 1/n, so all lines are equally likely. > > >

Re: Looping a script

2001-02-19 Thread rpjday
On Mon, 19 Feb 2001, Bret Hughes wrote: > rpjday wrote: > > > > actually, if you examine the algorithm, the probability that line n > > will be chosen as the "new" random line as you read through the file > > is precisely 1/n, so all lines are equally likely. > > I don't think that is what is hap

Re: Looping a script

2001-02-19 Thread Bret Hughes
rpjday wrote: > > actually, if you examine the algorithm, the probability that line n > will be chosen as the "new" random line as you read through the file > is precisely 1/n, so all lines are equally likely. I don't think that is what is happening here. I don't think that all lines are equall

Re: Looping a script

2001-02-19 Thread rpjday
On Mon, 19 Feb 2001, Bret Hughes wrote: > Johannes Eriksson wrote: > > > > * Bret Hughes [Mon, Feb 19, 2001 at 12:39:22AM -0600]: > > > i believe you. I just can't figure out what it is doing? I have been > > > working with perl lately and always looking to learn. Can you explain > > > what it

Re: Looping a script

2001-02-19 Thread Bret Hughes
Johannes Eriksson wrote: > > * Bret Hughes [Mon, Feb 19, 2001 at 12:39:22AM -0600]: > > i believe you. I just can't figure out what it is doing? I have been > > working with perl lately and always looking to learn. Can you explain > > what it is doing please? > Here's the same script in a les

Re: Looping a script

2001-02-19 Thread Johannes Eriksson
* Bret Hughes [Mon, Feb 19, 2001 at 12:39:22AM -0600]: > i believe you. I just can't figure out what it is doing? I have been > working with perl lately and always looking to learn. Can you explain > what it is doing please? > > this also appears to work: > perl -e 'rand($.)<1&&($l=$_)while<>;

Re: Looping a script

2001-02-19 Thread rpjday
On Mon, 19 Feb 2001, Bret Hughes wrote: > Johannes Eriksson wrote: > > > > > > perl -e 'rand;rand($.)<1&&($l=$_)while<>;print $l;' < file > > > > It works. Believe me. > > i believe you. I just can't figure out what it is doing? I have been > working with perl lately and always looking to lea

Re: Looping a script

2001-02-18 Thread Bret Hughes
Johannes Eriksson wrote: > > perl -e 'rand;rand($.)<1&&($l=$_)while<>;print $l;' < file > > It works. Believe me. i believe you. I just can't figure out what it is doing? I have been working with perl lately and always looking to learn. Can you explain what it is doing please? this also

Re: Looping a script

2001-02-18 Thread Ashley M. Kirchner
Johannes Eriksson wrote: > #!/usr/bin/perl > > srand; > for (;;) > { > @f = <*.mp3>; > @s=(); > (push(@s,splice(@f,rand @f,1))) while (@f); > map {system ("amp","-p",$_)} @s; > } > > It will loop ad inifinitum, playing all mp3 files in the working > directory randomly sh

Re: Looping a script

2001-02-18 Thread Johannes Eriksson
* Bret Hughes [Sun, Feb 18, 2001 at 09:01:39PM -0600]: > > *** random_line.sh *** > #!/bin/bash > > ## > ## Name: > ##random_line.sh > ## > ## Version: > ##$Revision: 1.2 $ > ## > ## Purpose: > ##Print a random line from a specified file. > #

Re: Looping a script

2001-02-18 Thread John H Darrah
On Sun, 18 Feb 2001, Ashley M. Kirchner wrote: > > a) If I do 'ls -AQU *.mp3', the result is always sorted. >However, if I just do 'ls -AQU' it's not sorted. > This little script should give you a randomized selection of the MP3's. -- cut -- #!/bin/bash let m=32768 n=0 while: do

Re: Looping a script

2001-02-18 Thread Bret Hughes
Dave Wreski wrote: > > > However, this will play the files sequentially, in (sorted) order. I > > want it to be randomized, like the output of 'ls -AQU' > > while [ 1 ] > do > for mp3 in `/bin/ls -AQU *.mp3` > do > amp -p $mp3 > done > done > see if

Re: Looping a script

2001-02-18 Thread John H Darrah
On Sun, 18 Feb 2001, Ashley M. Kirchner wrote: > > a) If I do 'ls -AQU *.mp3', the result is always sorted. >However, if I just do 'ls -AQU' it's not sorted. > The shell (bash?) is sorting them for you. Type: echo ls -AQU *.mp3 to see what the command looks like after th

Re: Looping a script

2001-02-18 Thread Johannes Eriksson
* Ashley M. Kirchner [Sun, Feb 18, 2001 at 04:52:21PM -0700]: > Dave Wreski wrote: > > > while [ 1 ] > > do > > for mp3 in `/bin/ls -AQU *.mp3` > > do > > amp -p $mp3 > > done > > done > > Hrm, something's not right. > > a) If I do 'ls -AQU *.mp3'

Re: Looping a script

2001-02-18 Thread Johannes Eriksson
* Vidiot [Sun, Feb 18, 2001 at 04:53:42PM -0600]: > >What's the best/safest way to loop a script over and over again? > > > >All it does is call a different program with arguments (it plays mp3 > >files) and I want it to loop and start again when it reaches the end. > > > >#!/bin/sh >

Re: Looping a script

2001-02-18 Thread Ashley M. Kirchner
Dave Wreski wrote: > while [ 1 ] > do > for mp3 in `/bin/ls -AQU *.mp3` > do > amp -p $mp3 > done > done Hrm, something's not right. a) If I do 'ls -AQU *.mp3', the result is always sorted. However, if I just do 'ls -AQU' it's not sorted.

Re: Looping a script

2001-02-18 Thread Ashley M. Kirchner
Vidiot wrote: > >while [ 1 ] > >do > > for mp3 in `/bin/ls -AQU *.mp3` > > do > > amp -p $mp3 > > done > >done > > But that isn't truly random either, because once a pass is completed, it > will repeat the same pass. That, is okay actually. There are enough s

Re: Looping a script

2001-02-18 Thread Vidiot
>> However, this will play the files sequentially, in (sorted) order. I >> want it to be randomized, like the output of 'ls -AQU' > >while [ 1 ] >do > for mp3 in `/bin/ls -AQU *.mp3` > do > amp -p $mp3 > done >done But that isn't truly random either, because o

Re: Looping a script

2001-02-18 Thread Vidiot
>Mike McNally wrote: > >> You can also make it play all .mp3 files in a directory >> like this: >> >> #!/bin/sh >> >> while :; do >>for mp3 in *.mp3; do >> amp -p "$mp3" >>done >> done > >However, this will play the files sequentially, in (sorted) order. I >want it to be randomi

Re: Looping a script

2001-02-18 Thread Dave Wreski
> However, this will play the files sequentially, in (sorted) order. I > want it to be randomized, like the output of 'ls -AQU' while [ 1 ] do for mp3 in `/bin/ls -AQU *.mp3` do amp -p $mp3 done done ___

Re: Looping a script

2001-02-18 Thread Ashley M. Kirchner
Mike McNally wrote: > You can also make it play all .mp3 files in a directory > like this: > > #!/bin/sh > > while :; do >for mp3 in *.mp3; do > amp -p "$mp3" >done > done However, this will play the files sequentially, in (sorted) order. I want it to be randomized, like the o

Re: Looping a script

2001-02-18 Thread rpjday
On Sun, 18 Feb 2001, Vidiot wrote: > >What's the best/safest way to loop a script over and over again? > > > >All it does is call a different program with arguments (it plays mp3 > >files) and I want it to loop and start again when it reaches the end. > > > >#!/bin/sh > >amp -p "f

Re: Looping a script

2001-02-18 Thread Vidiot
>What's the best/safest way to loop a script over and over again? > >All it does is call a different program with arguments (it plays mp3 >files) and I want it to loop and start again when it reaches the end. > >#!/bin/sh >amp -p "file one.mp3" >amp -p "file two.mp3" >...