xref: /netbsd/usr.bin/shuffle/shuffle.1 (revision bf9ec67e)
1.\"	$NetBSD: shuffle.1,v 1.3 2002/03/05 15:06:16 wiz Exp $
2.\"
3.\" Copyright (c) 1998
4.\" 	Perry E. Metzger.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgment:
16.\"	This product includes software developed for the NetBSD Project
17.\"	by Perry E. Metzger.
18.\" 4. The name of the author may not be used to endorse or promote products
19.\"    derived from this software without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31.\"
32.\"
33.Dd September 22, 1998
34.Dt SHUFFLE 1
35.Os
36.Sh NAME
37.Nm shuffle
38.Nd print a random permutation of the command line arguments
39.Sh SYNOPSIS
40.Nm
41.Op Fl f Ar filename ...
42.Op Fl n Ar number
43.Op Fl p Ar number
44.Op Ar arg
45.Op Ar ...
46.Sh DESCRIPTION
47The
48.Nm
49program prints a random permutation (or
50.Dq shuffle )
51of its command line arguments.
52This can be useful in shell scripts for selecting a
53random order in which to do a set of tasks, view a set of files, etc.
54.Pp
55If the
56.Fl f
57option is given, the data is taken from that files' contents or if the
58filename is
59.Ar -
60.Dq stdin .
61.Pp
62If the
63.Fl n
64option is given, its argument is treated as a number, and the program
65prints a random permutation of the numbers greater than or equal to 0
66and less than the argument.
67.Pp
68If the
69.Fl p
70option is given, its argument is treated as a number, and the program
71prints that number of randomly selected lines or arguments in a random order.
72.Sh EXAMPLES
73.Bd -literal -offset indent
74$ shuffle a b c d
75c
76b
77d
78a
79$ shuffle -p 1 a b c d
80d
81$ shuffle -n 4 -p 2
820
833
84.Ed
85.Sh SEE ALSO
86.Xr jot 1
87.Sh HISTORY
88The
89.Nm
90program first appeared in
91.Nx 1.4 .
92.Sh AUTHORS
93Written by Perry E. Metzger (perry@piermont.com).
94.Sh BUGS
95The random number generator isn't that great, and thus the
96permutations often aren't that great.
97