开发者

Bash shell script to randomly run different files

Wondering if anyone out there can offer up a short shell script that will randomly go through a directory and then "exec" a particular file. Essentially I'm looking for an mp3 shuffle kind of thing:

mp3_123.mp3 mp3_4开发者_如何学Go56.mp3 mp3_567.mp3 mp3_678.mp3

I could rename all the files so they're "mp3_1.mp3, mp3_2.mp3, etc." but I'd rather have it actually have (maybe?) an array of all the existing filenames, then pull out one randomly and play it on amarok or xine. (I'm assuming the latter part would be "...| exec amarok mp3_678.mp3" or something. But I don't know how to do the first part -- go through the filenames, make an array, then pull out a random array value and use that as the filename.

Any help would be great! Thank you!


find -iname '*/mp3' -print0 | rl -0 | xargs -r0 mplayer

As mentioned, sort -R has similar semantics to rl,

find -iname '*/mp3' -print0 | sort -z -R | xargs -r0 mplayer
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜