When I was working with a quick playlist creator script a few days ago, I noticed that the shuf Linux tool was missing from my Mac. This tool allows you to pipe lines of input into it, which then outputs those same lines in a shuffled order. I decided to create a quick PHP shell script which should be placed into a file named "shuf" in one of your bin directories. Unix scripts that use shuf should then be able to run if they use the command is a filter.
I would like to note that the full shuf command supports a number of other options such as how many lines to output as well as using a file as input. Currently the script does not support those options - you should be able to recreate them by piping the output into the head command, and reading from a file can be done using the cat command.
All article content is copyright of Michael Petrov, 2010©.
The source code presented in the articles is distributed as freeware, please feel free to use it in your own projects - both commercial and non commercial.![]()
