File: unsort.1

package info (click to toggle)
unsort 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 532 kB
  • ctags: 134
  • sloc: ansic: 1,401; sh: 1,042; makefile: 5
file content (103 lines) | stat: -rw-r--r-- 3,599 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
.Dd 2007-11-25
.Dt UNSORT 1
.Os "Free Software"
.Sh NAME
.Nm unsort
.Nd reorder lines in a file in semirandom ways
.Sh SYNOPSIS
.Nm
.Op Fl hvrpncmMsz0l
.Op Fl Fl help
.Op Fl Fl version
.Op Fl Fl random
.Op Fl Fl heuristic
.Op Fl Fl identity
.Op Fl Fl filenames Ns Ar [=profile]
.Op Fl Fl separator Ar sep
.Op Fl Fl concatenate
.Op Fl Fl merge
.Op Fl Fl merge-random
.Op Fl Fl seed Ar integer
.Op Fl Fl zero-terminated
.Op Fl Fl null
.Op Fl Fl linefeed
.Op Ar file No ...
.Sh DESCRIPTION
.Nm
prints the lines in the input files (or standard input) in semi-random order.
Available algorithms are a Mersenne Twister based PRNG and a heuristic
algorithm that aims to create a subjective even distribution.
.Ss Command line options
.Bl -tag -width indent
.It Fl h, Fl Fl help
Display a concise summary of the available options and argument syntax.
.It Fl v, Fl Fl version
Display version and copyright information.
.It Fl r, Fl Fl random
Use the Mersenne Twister based randomization algorithm.
.It Fl p, Fl Fl heuristic
Use the heuristic 
.Do
shuffling
.Dc
algorithm which permutes the lines in such a way
that they're spread more or less evenly in the output.
This is the default.
.It Fl n, Fl Fl identity
Do not reorder lines in the input. Useful if you just want to merge the files.
.It Fl f, Fl Fl filenames Ns Ar [=profile]
Assumes the input has a structure similar to filenames and apply randomization seperately to each directory level.
.Pp
An example would be a list of mp3 files where the top level is the genre, the second level is the name of the artist and the third level is the name of the album.
The
.Fl Fl filenames
option allows you to randomize the list with different randomization strategies for each of the artist, album and track levels.
.Pp
Two types of randomization are supported: simple and proportional.
Simple randomization picks one entry from each directory at that level in a round-robin fashion.
If one directory contains fewer entries than the others, it will run out and stop appearing at some point before the end of the output.
.Pp
Proportional randomization will spread the directory entries evenly over the output.
.Pp
The
.Ar profile
argument can be used to specify which randomization types to use.
It is a concatenation of the randomization types to use for each level.
Use
.Ar 1
for simple randomization and
.Ar n
for proportional randomization.
If the input has more levels than specified, the last character determines the randomization type for all subsequent levels.
.Pp
For example,
.Fl Fl filenames Ns = Ns Ar n1n
means: use proportional randomization for the genre, use simple randomization for the artists and use proportional randomization again for the album names and all levels below that.
.It Fl S, Fl Fl separator Ar sep
The directory separator to use with
.Fl f .
Defaults to 
.So
/
.Sc .
.It Fl r, Fl Fl concatenate
Concatenate all input files then apply the shuffling algorithm to the result
as a whole.
.It Fl m, Fl Fl merge
Shuffle all input files seperately then merge the result.
Equal-sized files will be merged in the order in which they appear on the
command line.
.It Fl M, Fl Fl merge-random
Shuffle all input files seperately then merge the result.
Equal-sized files will be merged in random order.
This is the default.
.It Fl s, Fl Fl seed Ar integer
Use this integer as a seed, instead of random data from the environment.
.It Fl z, Fl Fl zero-terminated, Fl 0, Fl Fl null
Lines are terminated with a \\0 character.
.It Fl l, Fl Fl linefeed
Lines are terminated with a \\n character.
This is the default.
.El
.Sh SEE ALSO
.Xr sort 1