|
|
1.1 root 1: .\" @(#)sort.1 6.4 (Berkeley) 9/30/87
2: .\"
3: .TH SORT 1 "September 30, 1987"
4: .AT 3
5: .SH NAME
6: sort \- sort or merge files
7: .SH SYNOPSIS
8: .B sort
9: [
10: .I -mubdfinrtx
11: ]
12: [ \fB+\fIpos1 \fR [ \fB\-\fIpos2 \fR]
13: ] ...
14: [
15: .B \-o
16: name ] [
17: .B \-T
18: directory ] [ name ] ...
19: .SH DESCRIPTION
20: .I Sort
21: sorts lines of all the named files together and writes the result on
22: the standard output. The name `\-' means the standard input.
23: If no input files are named, the standard input is sorted.
24: .LP
25: The default sort key is an entire line.
26: Default ordering is lexicographic by bytes in machine collating sequence.
27: The ordering is affected globally by the following options,
28: one or more of which may appear.
29: .TP 5
30: .B b
31: Ignore leading blanks (spaces and tabs) in field comparisons.
32: .TP 5
33: .B d
34: `Dictionary' order: only letters, digits and blanks
35: are significant in comparisons.
36: .TP 5
37: .B f
38: Fold upper case letters onto lower case.
39: .TP 5
40: .B i
41: Ignore characters outside the ASCII range 040-0176 in nonnumeric comparisons.
42: .TP 5
43: .B n
44: An initial numeric string, consisting of optional blanks, optional minus sign,
45: and zero or more digits with optional decimal point,
46: is sorted by arithmetic value. (Note that \fB-0\fP is considered equal
47: to \fB0\fP.) Option
48: .B n
49: implies option
50: .B b.
51: .TP 5
52: .B r
53: Reverse the sense of comparisons.
54: .TP 5
55: .BI t x
56: `Tab character' separating fields is
57: .IR x .
58: .LP
59: The notation
60: .BI + "pos1 " "\-\fIpos2"
61: restricts a sort key to a field beginning at
62: .I pos1
63: and ending just before
64: .IR pos2 .
65: .I Pos1
66: and
67: .I pos2
68: each have the form
69: .IB m . n\fR,
70: optionally followed by one or more of the flags
71: .B bdf\&inr,
72: where
73: .I m
74: tells a number of fields to skip from the beginning of the line and
75: .I n
76: tells a number of characters to skip further.
77: If any flags are present they override all the global
78: ordering options for this key. If the
79: .B b
80: option is in effect
81: .I n
82: is counted from the first nonblank in the field;
83: .B b
84: is attached independently to
85: .IR pos2 .
86: A missing \&\fB.\fIn\fR means .0; a missing
87: .BI \- pos2
88: means the end of the line. Under the
89: .BI \-t x
90: option, fields are strings separated by
91: .IR x ;
92: otherwise fields are nonempty nonblank strings separated by blanks.
93: .LP
94: When there are multiple sort keys, later keys
95: are compared only after all earlier keys compare equal.
96: Lines that otherwise compare equal are ordered with all bytes significant.
97: .LP
98: These option arguments are also understood:
99: .TP 5
100: .B c
101: Check that the input file is sorted according to the ordering rules;
102: give no output unless the file is out of sort.
103: .TP 5
104: .B m
105: Merge only, the input files are already sorted.
106: .TP 5
107: .B o
108: The next argument is the name of an output file
109: to use instead of the standard output.
110: This file may be the same as one of the inputs.
111: .TP 5
112: .B T
113: The next argument is the name of a directory in which temporary files
114: should be made.
115: .TP 5
116: .B u
117: Suppress all but one in each set of equal lines.
118: Ignored bytes and bytes outside keys do not participate in this comparison.
119: .SH EXAMPLES
120: .LP
121: Print in alphabetical order all the unique spellings in a list of words.
122: Capitalized words differ from uncapitalized.
123: .LP
124: .ti +8
125: sort \-u +0f +0 list
126: .LP
127: Print the password file
128: .RI ( passwd (5))
129: sorted by user id number (the 3rd colon-separated field).
130: .LP
131: .ti +8
132: sort \-t: +2n /etc/passwd
133: .LP
134: Print the first instance of each month in an already sorted file
135: of (month day) entries.
136: The options
137: .B \-um
138: with just one input file make the choice of a
139: unique representative from a set of equal lines predictable.
140: .LP
141: .ti +8
142: sort \-um +0 \-1 dates
143: .SH FILES
144: /usr/tmp/stm*, /tmp/* first and second tries for
145: temporary files
146: .SH "SEE ALSO"
147: uniq(1),
148: comm(1),
149: rev(1),
150: join(1)
151: .SH DIAGNOSTICS
152: Comments and exits with nonzero status for various trouble
153: conditions and for disorder discovered under option
154: .BR \-c .
155: .SH BUGS
156: Very long lines are silently truncated.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.