Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
RANDOM(6)		       BSD Games Manual			     RANDOM(6)

     random -- random lines from a file	or random numbers

     random [-elrUuw] [-f filename] [denominator]

     Random has	two distinct modes of operations.  The default is to read
     lines from	standard input and write them to standard output with a	proba-
     bility of 1.0 / denominator.  (denominator	is a real number greater than
     or	equal to 1.0.)	The default denominator	for this mode of operation is
     2.0, giving each line a 50% chance	of being displayed.

     The second	mode of	operation, selected with the -f	filename option, reads
     the specified file	and outputs the	randomized contents to standard	out-
     put.  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	isspace(3).)  The default denominator for this mode of operation is
     1.0, which	displays every line.

     The options are as	follows:

     -e	     If	the -e option is specified, random does	not read or write any-
	     thing, and	simply exits with a random exit	value of 0 to
	     denominator - 1, inclusive.  In this mode,	denominator must be
	     less than or equal	to 256.

     -f	filename
	     The -f option is used to specify the filename to read from.
	     Standard input is used if filename	is `-'.

     -l	     Randomize the input via newlines (the default).

     -r	     Do	not buffer output.

     -U	     Reuse any given line or word when creating	a randomized output.

     -u	     Do	not select the same line or word from a	file more than once
	     (the default).  This does not guarantee uniqueness	if there are
	     two of the	same tokens in the input.

     -w	     Randomize words separated by isspace(3) instead of	newlines.


     The functionality to randomizing lines and	words was added	in 2003	by
     Sean Chittenden <>.

     This tool is a remnant of the "games" collection formerly part of FreeBSD
     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.

     No	index is used when printing out	tokens from the	list which makes it
     rather slow for large files (10MB+).

BSD			       February	15, 2020			   BSD


Want to link to this manual page? Use this URL:

home | help