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 this helps. When passed a filename that contains a list of
filenames it will return a random line from the file:

you could do something like:

while true
do
        
        amp -p `random_line.sh filelist`
done
snip between the *** lines, copy to random_line.sh and you should be
good to go.  I had a randomization question a while back and the guys on
the shell.scripting list came up with this so I can't take credit for it
:-)
 
*************************** random_line.sh *******************
#!/bin/bash

## 
## Name:
##    random_line.sh
##
## Version:
##    $Revision: 1.2 $
##
## Purpose:
##    Print a random line from a specified file.
##
## Usage:
##    random_line.sh <filename>
##
## Author:
##    Todd A. Jacobs <[EMAIL PROTECTED]>
##

[ "$#" = "0" ] && {
        echo "usage: random_line.sh <filename>"
        exit -1
}

[ ! -f "$1" ] && {
        echo "$1: No such file."
        exit -2
}



# Get number of lines in file.
_LINES=$(wc -l < $1)
      
# Pick a random line number.
_RANDOM_LINE=$(( $RANDOM % $_LINES + 1 ))

# Deliver a single line of output.
head -n $_RANDOM_LINE < $1 | tail -n 1

******************************************************************



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to