Commit | Line | Data |
---|---|---|
de2c8a62 WJ |
1 | .\" Copyright (c) 1991 Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
6 | .\" | |
7 | .\" Redistribution and use in source and binary forms, with or without | |
8 | .\" modification, are permitted provided that the following conditions | |
9 | .\" are met: | |
10 | .\" 1. Redistributions of source code must retain the above copyright | |
11 | .\" notice, this list of conditions and the following disclaimer. | |
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer in the | |
14 | .\" documentation and/or other materials provided with the distribution. | |
15 | .\" 3. All advertising materials mentioning features or use of this software | |
16 | .\" must display the following acknowledgement: | |
17 | .\" This product includes software developed by the University of | |
18 | .\" California, Berkeley and its contributors. | |
19 | .\" 4. Neither the name of the University nor the names of its contributors | |
20 | .\" may be used to endorse or promote products derived from this software | |
21 | .\" without specific prior written permission. | |
22 | .\" | |
23 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
24 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
25 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
26 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
27 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
28 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
29 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
30 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
31 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
33 | .\" SUCH DAMAGE. | |
34 | .\" | |
35 | .\" @(#)uniq.1 6.4 (Berkeley) 6/27/91 | |
36 | .\" | |
37 | .Dd June 27, 1991 | |
38 | .Dt UNIQ | |
39 | .Os | |
40 | .Sh NAME | |
41 | .Nm uniq | |
42 | .Nd Report or filter out repeated lines in a file. | |
43 | .Sh SYNOPSIS | |
44 | .Nm uniq | |
45 | .Op Fl c | Fl d | Fl u | |
46 | .Op Fl f Ar fields | |
47 | .Op Fl s Ar chars | |
48 | .Oo | |
49 | .Ar input_file | |
50 | .Op Ar output_file | |
51 | .Oc | |
52 | .Pp | |
53 | Deprecated Version: | |
54 | .Pp | |
55 | .Nm uniq | |
56 | .Op Fl cdu | |
57 | .Op Fl Ns Ar n | |
58 | .Op Cm \(pl Ns Ar n | |
59 | .Oo | |
60 | .Ar input_file | |
61 | .Op Ar output_file | |
62 | .Oc | |
63 | .Sh DESCRIPTION | |
64 | The | |
65 | .Nm uniq | |
66 | utility reads an input file or the standard input | |
67 | comparing adjacent | |
68 | lines, and writes one copy of each input line on the output. | |
69 | The second and succeeding copies of repeated adjacent input | |
70 | lines are not written. | |
71 | Repeated lines in the input are not detected if they are | |
72 | not adjacent, so it is important to | |
73 | .Xr sort 1 | |
74 | the files first. | |
75 | .Pp | |
76 | The following options are available: | |
77 | .Bl -tag -width Ds | |
78 | .It Fl c | |
79 | Precede each output line with a count of the number | |
80 | of times the line occurred in the input. For example: | |
81 | .Bd -literal -offset indent | |
82 | duplicate_count line_number | |
83 | .Ed | |
84 | .Pp | |
85 | where the duplicate count is a blank padded field of | |
86 | up to four digits followed by a space. | |
87 | .It Fl d | |
88 | Suppress the writing of lines that are not repeated | |
89 | in the input. | |
90 | .It Fl f Ar fields | |
91 | Ignore the first fields on each input line when | |
92 | doing comparisons, where fields is a positive | |
93 | decimal integer. | |
94 | A field is a string of non-blank | |
95 | characters separated from adjacent fields | |
96 | by blanks. | |
97 | .It Fl s Ar chars | |
98 | Ignore the first chars characters when doing | |
99 | comparisons, where chars is a positive decimal | |
100 | integer. | |
101 | If specified in conjunction with the | |
102 | .Fl f | |
103 | option, the first chars characters after the first | |
104 | fields fields will be ignored. | |
105 | .It Fl u | |
106 | Suppress the writing of lines that are repeated in | |
107 | the input. | |
108 | .It Fl Ns Ar n | |
109 | (Deprecated; replaced by | |
110 | .Fl f ) . | |
111 | Ignore the first n | |
112 | fields on each input line when doing comparisons, | |
113 | where n is a number. | |
114 | A field is a string of non-blank | |
115 | characters separated from adjacent fields | |
116 | by blanks. | |
117 | .It Cm \&\(pl Ns Ar n | |
118 | (Deprecated; replaced by | |
119 | .Fl s ) . | |
120 | Ignore the first | |
121 | .Ar m | |
122 | characters when doing comparisons, where | |
123 | .Ar m | |
124 | is a | |
125 | number. | |
126 | .El | |
127 | .Pp | |
128 | The following operands are available: | |
129 | .Bl -tag -width output_filex | |
130 | .It Ar input_file | |
131 | A pathname of the input file. | |
132 | If the | |
133 | .Ar input_file | |
134 | operand is not specified, the standard input is | |
135 | used. | |
136 | .It Ar output_file | |
137 | A pathname of the output file. | |
138 | This name shall | |
139 | always be different from | |
140 | .Ar input_file. | |
141 | If the | |
142 | .Ar output_file | |
143 | operand is not specified, the standard | |
144 | output is used. If | |
145 | .Ar output_file | |
146 | is created and an error occurs or a sugnal is caught the | |
147 | .Ar output_file | |
148 | is not removed. | |
149 | .El | |
150 | .\" .Pp | |
151 | .\" The following environment variables affect the execution of | |
152 | .\" uniq: | |
153 | .\" .Tl Em LC_CTYPE | |
154 | .\" The locale for character classification, used to | |
155 | .\" determine the characters constituting a blank in | |
156 | .\" the current locale. | |
157 | .Pp | |
158 | The | |
159 | .Xr uniq | |
160 | utility exits 0 on success, and >0 if an error occurs. | |
161 | .Sh STANDARDS | |
162 | The | |
163 | .Xr uniq | |
164 | utility is expected to be | |
165 | .St -p1003.2 | |
166 | compatible. |