1994-09-04 04:03:31 +00:00
|
|
|
.\" Copyright (c) 1994
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
2010-12-06 19:12:51 +00:00
|
|
|
.\" 3. Neither the name of the University nor the names of its contributors
|
1994-09-04 04:03:31 +00:00
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)random.6 8.2 (Berkeley) 3/31/94
|
1999-08-27 23:37:10 +00:00
|
|
|
.\" $FreeBSD$
|
1994-09-04 04:03:31 +00:00
|
|
|
.\"
|
2003-02-11 19:32:18 +00:00
|
|
|
.Dd February 8, 2003
|
1994-09-04 04:03:31 +00:00
|
|
|
.Dt RANDOM 6
|
2001-07-10 10:42:19 +00:00
|
|
|
.Os
|
1994-09-04 04:03:31 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm random
|
|
|
|
.Nd random lines from a file or random numbers
|
|
|
|
.Sh SYNOPSIS
|
2000-11-20 12:06:19 +00:00
|
|
|
.Nm
|
2003-02-23 01:44:14 +00:00
|
|
|
.Op Fl elrUuw
|
2003-02-11 19:32:18 +00:00
|
|
|
.Op Fl f Ar filename
|
1994-09-04 04:03:31 +00:00
|
|
|
.Op Ar denominator
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Nm Random
|
2003-02-23 01:44:14 +00:00
|
|
|
has two distinct modes of operations.
|
|
|
|
The default is to read in lines
|
|
|
|
from the standard input and randomly write them out
|
|
|
|
to the standard output with a probability of
|
2003-02-11 19:32:18 +00:00
|
|
|
1 /
|
|
|
|
.Ar denominator .
|
|
|
|
The default
|
1994-09-04 04:03:31 +00:00
|
|
|
.Ar denominator
|
2003-02-11 19:32:18 +00:00
|
|
|
for this mode of operation is 2, giving each line a 50/50 chance of
|
|
|
|
being displayed.
|
|
|
|
.Pp
|
|
|
|
The second mode of operation is to read in a file from
|
|
|
|
.Ar filename
|
2003-02-23 01:44:14 +00:00
|
|
|
and randomize the contents of the file and send it back out to
|
|
|
|
standard output.
|
2003-02-11 19:32:18 +00:00
|
|
|
The contents can be randomized based off of newlines or based off of
|
|
|
|
space characters as determined by
|
|
|
|
.Xr isspace 3 .
|
|
|
|
The default
|
|
|
|
.Ar denominator
|
|
|
|
for this mode of operation is 1, which gives each line a chance to be
|
|
|
|
displayed, but in a
|
|
|
|
.Xr random 3
|
|
|
|
order.
|
1994-09-04 04:03:31 +00:00
|
|
|
.Pp
|
|
|
|
The options are as follows:
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Fl e
|
|
|
|
If the
|
|
|
|
.Fl e
|
|
|
|
option is specified,
|
2000-11-20 12:06:19 +00:00
|
|
|
.Nm
|
1994-09-04 04:03:31 +00:00
|
|
|
does not read or write anything, and simply exits with a random
|
|
|
|
exit value of 0 to
|
|
|
|
.Ar denominator
|
|
|
|
\&- 1, inclusive.
|
2003-02-11 19:32:18 +00:00
|
|
|
.It Fl f Ar filename
|
|
|
|
The
|
|
|
|
.Fl f
|
|
|
|
option is used to specify the
|
|
|
|
.Ar filename
|
2003-02-23 01:44:14 +00:00
|
|
|
to read from.
|
|
|
|
Standard input is used if
|
|
|
|
.Ar filename
|
|
|
|
is set to
|
|
|
|
.Sq Fl .
|
2003-02-11 19:32:18 +00:00
|
|
|
.It Fl l
|
|
|
|
Randomize the input via newlines (the default).
|
1994-09-04 04:03:31 +00:00
|
|
|
.It Fl r
|
|
|
|
The
|
|
|
|
.Fl r
|
|
|
|
option guarantees that the output is unbuffered.
|
2003-02-23 01:44:14 +00:00
|
|
|
.It Fl U
|
|
|
|
Tells
|
|
|
|
.Xr random 6
|
|
|
|
that it is okay for it to reuse any given line or word when creating a
|
|
|
|
randomized output.
|
2003-02-11 19:32:18 +00:00
|
|
|
.It Fl u
|
|
|
|
Tells
|
|
|
|
.Xr random 6
|
|
|
|
not to select the same line or word from a file more than once (the
|
2003-02-23 01:44:14 +00:00
|
|
|
default).
|
|
|
|
This does not guarantee uniqueness if there are two of the
|
2003-02-11 19:32:18 +00:00
|
|
|
same tokens from the input, but it does prevent selecting the same
|
|
|
|
token more than once.
|
|
|
|
.It Fl w
|
|
|
|
Randomize words separated by
|
|
|
|
.Xr isspace 3
|
|
|
|
instead of newlines.
|
1994-09-04 04:03:31 +00:00
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
2003-02-23 01:44:14 +00:00
|
|
|
.Xr random 3 ,
|
|
|
|
.Xr fortune 6
|
2005-01-18 08:57:18 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
functionality to randomizing lines and words was added in 2003 by
|
2014-06-20 09:40:43 +00:00
|
|
|
.An Sean Chittenden Aq Mt seanc@FreeBSD.org .
|
2003-02-11 19:32:18 +00:00
|
|
|
.Sh BUGS
|
2003-02-23 01:44:14 +00:00
|
|
|
No index is used when printing out tokens from the list which
|
|
|
|
makes it rather slow for large files (10MB+).
|
|
|
|
For smaller
|
2003-02-11 19:32:18 +00:00
|
|
|
files, however, it should still be quite fast and efficient.
|