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
|
|
|
.\"
|
2020-02-15 19:13:37 +00:00
|
|
|
.Dd February 15, 2020
|
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.
|
2020-02-15 19:13:37 +00:00
|
|
|
The default is to read lines from standard input and write them to standard
|
|
|
|
output with a probability of 1.0 /
|
2003-02-11 19:32:18 +00:00
|
|
|
.Ar denominator .
|
2020-02-15 19:13:37 +00:00
|
|
|
.Ar ( denominator
|
|
|
|
is a real number greater than or equal to 1.0.)
|
2003-02-11 19:32:18 +00:00
|
|
|
The default
|
1994-09-04 04:03:31 +00:00
|
|
|
.Ar denominator
|
2020-02-15 19:13:37 +00:00
|
|
|
for this mode of operation is 2.0, giving each line a 50% chance of
|
2003-02-11 19:32:18 +00:00
|
|
|
being displayed.
|
|
|
|
.Pp
|
2020-02-15 19:13:37 +00:00
|
|
|
The second mode of operation, selected with the
|
|
|
|
.Fl f Ar filename
|
|
|
|
option, reads the specified file and outputs the randomized contents to
|
2003-02-23 01:44:14 +00:00
|
|
|
standard output.
|
2020-02-15 19:13:37 +00:00
|
|
|
The contents can be randomized in units of lines (split on newline characters)
|
|
|
|
or in units of words (split on space characters as determined by
|
|
|
|
.Xr isspace 3 . )
|
2003-02-11 19:32:18 +00:00
|
|
|
The default
|
|
|
|
.Ar denominator
|
2020-02-15 19:13:37 +00:00
|
|
|
for this mode of operation is 1.0, which displays every line.
|
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.
|
2020-02-15 19:13:37 +00:00
|
|
|
In this mode,
|
|
|
|
.Ar denominator
|
|
|
|
must be less than or equal to 256.
|
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
|
2020-02-15 19:13:37 +00:00
|
|
|
is
|
|
|
|
.Sq - .
|
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
|
2020-02-15 19:13:37 +00:00
|
|
|
Do not buffer output.
|
2003-02-23 01:44:14 +00:00
|
|
|
.It Fl U
|
2020-02-15 19:13:37 +00:00
|
|
|
Reuse any given line or word when creating a randomized output.
|
2003-02-11 19:32:18 +00:00
|
|
|
.It Fl u
|
2020-02-15 19:13:37 +00:00
|
|
|
Do not select the same line or word from a file more than once (the default).
|
2003-02-23 01:44:14 +00:00
|
|
|
This does not guarantee uniqueness if there are two of the
|
2020-02-15 19:13:37 +00:00
|
|
|
same tokens in the input.
|
2003-02-11 19:32:18 +00:00
|
|
|
.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 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
|
2020-02-15 19:13:37 +00:00
|
|
|
This tool is a remnant of the "games" collection formerly part of
|
|
|
|
.Fx
|
|
|
|
base.
|
|
|
|
It probably should have been removed to ports with the rest of that collection.
|
|
|
|
It does not have a coherent purpose and the motivation for it to be a core base
|
|
|
|
utility is nonobvious.
|
|
|
|
.Pp
|
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+).
|