rl - Randomize Lines rl reads lines from a input file or stdin, randomizes the lines and outputs a specified number of lines. It does this with only a single pass over the input while trying to use as little memory as possible. I wrote rl in my spare time mainly to be able to select a random audio file to play when my toast is done (script in combination with find and sleep). Another reason was to familiarize myself with autoconf and friends. The most recent version of this page can be found at http://tiefighter.et.tudelft.nl/~arthur/rl/. Warning: rl is alpha software and has not been thoroughly tested yet. The command line options and default behavior may even change between releases. Download COPYRIGHT NOTICE ---------------- Copyright (C) 2002 Arthur de Jong rl is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA INSTALLATION INSTRUCTIONS ------------------------- rl should compile fine on most Unix-like operating systems. It is written to be as portable as possible. rl is developed on Debian GNU/Linux 2.2 and tested on Solaris 7 (regularly), OpenBSD 2.7 (sometimes) and HP-UX 10 (hardly ever). rl uses a configure script to guess build parameters for your system. Configuration, compilation and installation would be as simple as one, two, three: % ./configure (use --help for options) % make (compile) % make install (install) For more details read the INSTALL file. CVS (not there yet) ------------------- I have not set up a anonymous cvs pserver yet, but I'm working on it. The drill to get the files from cvs should be something like: % cvs -d:pserver:anoncvs@somewhere:/somewhere login (passwd=anoncvs) % cvs -z3 -d:pserver:anoncvs@somewhere:/somewhere checkout rl This should check out all files from CVS. Some files need to be generated however. From the checked out rl directory: % aclocal (to create aclocal.m4) % autoheader (to create config.h.in) % automake (to create Makefile.in) % autoconf (to create configure) From there the standard configure/make stuff described above should work. PLANS / TODO ------------ rl is still in development and there are more features to implement. The development is currently based on the "it works for me" principle. Things to do: * I should figure out how to create a Debian package. * The memory management can probably be improved a bit here and there avoiding a lot of calls to malloc() and free(), especially when multiple input files are read. * I would like to experiment with using temporary files instead of allocating memory which might improve performance with very large input data. * The currently used random generator is rand() which is seeded with the process id and the current time in microseconds. This method does not in any way provide cryptographicly strong random values. It might be a good idea to look in to cryptographicly strong random number generators for picking a line (low priority though). * Maybe there need to be more options added for some things like verbosity of error messages. * Another method for picking out a line in a file is to do a random fseek() in a file and find the matching line. Using this longer lines have a higher probability of being picked, but it is lot faster for picking a low number of lines. * Find out for which file sizes the random numbers produce accurate results. This really needs some work since some systems (HP-UX and Solaris) have a very low RAND_MAX. * Add an option to specify another delimiter. If you want any features added to rl or you have comments or questions you can email me at arthur@tiefighter.et.tudelft.nl. Patches for bug fixes and feature extensions are appreciated. FUN AND USEFULL THINGS TO DO WITH RL ------------------------------------ * sleep 240 ; play `find /sounds -name '*.au' -print | rl --count=1` Play a random sound after 4 minutes (perfect for toast). * renice +5 -u `who | cut '-d ' -f 1 | sort -u | rl --count=1` Renice all the processes of a random logged-in user. * kill -9 `ps -A | cut '-d ' -f 2 | rl --count=1` Kill a random process on your computer. Do this as root and see how long your system keeps working. Increase the --count for extra effect. (you might need to change the ps parameters depending on your system) LINKS ----- You might want to have a look at the rl Freshmeat page: http://freshmeat.net/projects/rl/ Other similar programs? Other links? Any comment? Email me at: arthur@tiefighter.et.tudelft.nl