randline - deliver random line(s)
randline selects a random line or lines from its input,
either standard input or the named files.
The algorithm used is the classic one-pass one described in Knuth,
with a couple of extensions.
There are a few options:
- (``keep header'')
Always pass through the first line of the input
(which is assumed to be a header of some sort);
perform random selection from among the remaining lines.
- -n n
- (or just -n)
Select n lines.
When selecting more than one line,
print them out in the same order they were in in the input,
- -seed s
- Use initial random seed s.
- -seedfile f
- Save random seed state in file f
for repeatable behavior between runs.
- Print program's version number.
- Use weighted probabilities when selecting lines.
(or last, whichever looks numeric)
column on each input
line gives its ``weight''.
Lines with higher weights are selected
with higher probability:
if two lines a and b have weights in the ratio m:n,
line a will be selected m/n times as often as line b.
of the selected lines
are not printed on output.)
- Another way of thinking about this is that
if an input line has weight w,
the behavior is the same as if that line appeared
in the input
- (This feature is still somewhat experimental.)
- -?, -help
- Print a brief help message.
There is a fixed limit
on the longest input line that can be read.
There is no provision for
fractional or floating-point weights
under the -w option;
all weights must be integral.
The program is based on the algorithm in Knuth, section xxx.
This documentation corresponds to version 3.01 of the program.
for possible updates.