Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / uniq.1
blob0dd9a80beff20d24705b58810453d6c7310015b4
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
46 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
47 .\"
48 .TH UNIQ 1 "Mar 13, 2008"
49 .SH NAME
50 uniq \- report or filter out repeated lines in a file
51 .SH SYNOPSIS
52 .SS "/usr/bin/uniq"
53 .LP
54 .nf
55 \fB/usr/bin/uniq\fR [\fB-c\fR | \fB-d\fR | \fB-u\fR] [\fB-f\fR \fIfields\fR] [\fB-s\fR \fIchar\fR]
56      [\fIinput_file\fR [\fIoutput_file\fR]]
57 .fi
59 .LP
60 .nf
61 \fB/usr/bin/uniq\fR [\fB-c\fR | \fB-d\fR | \fB-u\fR] [\fB-n\fR] [+ \fIm\fR] [\fIinput_file\fR [\fIoutput_file\fR]]
62 .fi
64 .SS "ksh93"
65 .LP
66 .nf
67 \fBuniq\fR [\fB-cdiu\fR] [\fB-D\fR[\fIdelimit\fR]] [\fB-f\fR \fIfields\fR] [\fB-s\fR \fIchars\fR] [\fB-w\fR \fIchars\fR]
68      [\fIinput_file\fR [\fIoutput_file\fR]]
69 .fi
71 .LP
72 .nf
73 \fBuniq\fR [\fB-cdiu\fR] [\fB-D\fR[\fIdelimit\fR]] [\fB-n\fR] [\fB+m\fR] [\fB-w\fR \fIchars\fR] [\fIinput_file\fR [\fIoutput_file\fR]]
74 .fi
76 .SH DESCRIPTION
77 .SS "/usr/bin/uniq"
78 .sp
79 .LP
80 The \fBuniq\fR utility reads an input file comparing adjacent lines and writes
81 one copy of each input line on the output. The second and succeeding copies of
82 repeated adjacent input lines are not written.
83 .sp
84 .LP
85 Repeated lines in the input are not detected if they are not adjacent.
86 .SS "ksh93"
87 .sp
88 .LP
89 The \fBuniq\fR built-in in \fBksh93\fR is associated with the \fB/bin\fR or
90 \fB/usr/bin path\fR. It is invoked when \fBuniq\fR is executed without a
91 pathname prefix and the pathname search finds a \fB/bin/uniq\fR or
92 \fB/usr/bin/uniq\fR executable.
93 .sp
94 .LP
95 \fBuniq\fR reads an input, comparing adjacent lines, and writing one copy of
96 each input line on the output. The second and succeeding copies of the repeated
97 adjacent lines are not written.
98 .sp
99 .LP
100 If \fIoutput_file\fR is not specified, \fBuniq\fR writes to standard output. If
101 \fIinput_file\fR is not specified, or if \fIinput_file\fR is \fB-\fR,
102 \fBuniq\fR reads from standard input, and the start of the file is defined as
103 the current offset.
104 .SH OPTIONS
105 .SS "/usr/bin/uniq"
108 The following options are supported by \fB/usr/bin/uniq\fR:
110 .ne 2
112 \fB\fB-c\fR\fR
114 .RS 13n
115 Precedes each output line with a count of the number of times the line occurred
116 in the input.
120 .ne 2
122 \fB\fB-d\fR\fR
124 .RS 13n
125 Suppresses the writing of lines that are not repeated in the input.
129 .ne 2
131 \fB\fB-f\fR \fIfields\fR\fR
133 .RS 13n
134 Ignores the first \fIfields\fR fields on each input line when doing
135 comparisons, where \fIfields\fR is a positive decimal integer. A field is the
136 maximal string matched by the basic regular expression:
138 .in +2
140 [[:blank:]]*[^[:blank:]]*
142 .in -2
145 If \fIfields\fR specifies more fields than appear on an input line, a null
146 string is used for comparison.
150 .ne 2
152 \fB\fB+\fR\fIm\fR\fR
154 .RS 13n
155 Equivalent to \fB-s\fR \fIchars\fR with \fIchars\fR set to \fIm\fR.
159 .ne 2
161 \fB\fB\(mi\fR\fIn\fR\fR
163 .RS 13n
164 Equivalent to \fB-f\fR \fIfields\fR with \fIfields\fR set to \fIn\fR.
168 .ne 2
170 \fB\fB-s\fR \fIchars\fR\fR
172 .RS 13n
173 Ignores the first \fIchars\fR characters when doing comparisons, where
174 \fIchars\fR is a positive decimal integer. If specified in conjunction with the
175 \fB-f\fR option, the first \fIchars\fR characters after the first \fIfields\fR
176 fields is ignored. If \fIchars\fR specifies more characters than remain on an
177 input line, a null string is used for comparison.
181 .ne 2
183 \fB\fB-u\fR\fR
185 .RS 13n
186 Suppresses the writing of lines that are repeated in the input.
189 .SS "ksh93"
192 The following options are supported by the \fBuniq\fR built-in command is
193 \fBksh93\fR:
195 .ne 2
197 \fB\fB-c\fR\fR
201 \fB\fB--count\fR\fR
203 .RS 28n
204 Outputs the number of times each line occurred along with the line.
208 .ne 2
210 \fB\fB-d\fR\fR
214 \fB\fB--repeated | duplicates\fR\fR
216 .RS 28n
217 Outputs only duplicate lines.
221 .ne 2
223 \fB\fB-D\fR\fR
227 \fB\fB--all-repeated\fR[\fB=\fR\fIdelimit\fR]\fR
229 .RS 28n
230 Outputs all duplicate lines as a group with an empty line delimiter specified
231 by \fIdelimit\fR.
233 Specify \fIdelimit\fR as one of the following:
235 .ne 2
237 \fB\fBnone\fR\fR
239 .RS 12n
240 Do not delimit duplicate groups.
244 .ne 2
246 \fB\fBprepend\fR\fR
248 .RS 12n
249 Prepend an empty line before each group.
253 .ne 2
255 \fB\fBseparate\fR\fR
257 .RS 12n
258 Separate each group with an empty line.
261 The value for \fIdelimit\fR can be omitted. The default value is \fBnone\fR.
265 .ne 2
267 \fB\fB-f\fR\fR
271 \fB\fB--skip-fields=\fR\fIfields\fR\fR
273 .RS 28n
274 Skips over \fIfields\fR number of fields before checking for uniqueness. A
275 field is the minimal string matching the \fBBRE
276 [[:\fR\fIblank\fR\fB:]]*[^[:\fR\fIblank\fR\fB:]]*\fR.
280 .ne 2
282 \fB\fB-i\fR\fR
286 \fB\fB--ignore-case\fR\fR
288 .RS 28n
289 Ignore case in comparisons.
293 .ne 2
295 \fB\fB+\fR\fIm\fR\fR
297 .RS 28n
298 Equivalent to the \fB-s\fR \fIchars\fR option, with \fIchars\fR set to \fIm\fR.
302 .ne 2
304 \fB\fB-\fR\fIn\fR\fR
306 .RS 28n
307 Equivalent to the \fB-f\fR \fIfields\fR option, with \fIfields\fR set to
308 \fIn\fR.
312 .ne 2
314 \fB\fB-s\fR\fR
318 \fB\fB--skip-chars=\fR\fIchars\fR\fR
320 .RS 28n
321 Skips over \fIchars\fR number of characters before checking for uniqueness.
323 If specified with the \fB-f\fR option, the first \fIchars\fR after the first
324 fields are ignored. If the \fIchars\fR specifies more characters than are on
325 the line, an empty string is used for comparison.
329 .ne 2
331 \fB\fB-u\fR\fR
335 \fB\fB--uniq\fR\fR
337 .RS 28n
338 Outputs unique lines.
342 .ne 2
344 \fB\fB-w\fR\fR
348 \fB\fB--check-chars=\fR\fIchars\fR\fR
350 .RS 28n
351 Skips over any specified fields and characters, then compares \fIchars\fR
352 number of characters.
355 .SH OPERANDS
358 The following operands are supported:
360 .ne 2
362 \fB\fIinput_file\fR\fR
364 .RS 15n
365 A path name of the input file. If \fIinput_file\fR is not specified, or if the
366 \fIinput_file\fR is \fB\(mi\fR, the standard input is used.
370 .ne 2
372 \fB\fIoutput_file\fR\fR
374 .RS 15n
375 A path name of the output file. If \fIoutput_file\fR is not specified, the
376 standard output is used. The results are unspecified if the file named by
377 \fIoutput_file\fR is the file named by \fIinput_file\fR.
380 .SH EXAMPLES
382 \fBExample 1 \fRUsing the \fBuniq\fR Command
385 The following example lists the contents of the \fBuniq.test\fR file and
386 outputs a copy of the repeated lines.
389 .in +2
391 example% \fBcat uniq.test\fR
392 This is a test.
393 This is a test.
394 TEST.
395 Computer.
396 TEST.
397 TEST.
398 Software.
400 example% \fBuniq -d uniq.test\fR
401 This is a test.
402 TEST.
403 example%
405 .in -2
410 The next example outputs just those lines that are not repeated in the
411 \fBuniq.test\fR file.
414 .in +2
416 example% \fBuniq -u uniq.test\fR
417 TEST.
418 Computer.
419 Software.
420 example%
422 .in -2
427 The last example outputs a report with each line preceded by a count of the
428 number of times each line occurred in the file:
431 .in +2
433 example% \fBuniq -c uniq.test\fR
434    2 This is a test.
435    1 TEST.
436    1 Computer.
437    2 TEST.
438    1 Software.
439 example%
441 .in -2
444 .SH ENVIRONMENT VARIABLES
447 See \fBenviron\fR(5) for descriptions of the following environment variables
448 that affect the execution of \fBuniq\fR: \fBLANG\fR, \fBLC_ALL\fR,
449 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
450 .SH EXIT STATUS
453 The following exit values are returned:
455 .ne 2
457 \fB\fB0\fR\fR
459 .RS 6n
460 Successful completion.
464 .ne 2
466 \fB\fB>0\fR\fR
468 .RS 6n
469 An error occurred.
472 .SH ATTRIBUTES
475 See \fBattributes\fR(5) for descriptions of the following attributes:
476 .SS "/usr/bin/uniq"
481 box;
482 c | c
483 l | l .
484 ATTRIBUTE TYPE  ATTRIBUTE VALUE
486 CSI     Enabled
488 Interface Stability     Committed
490 Standard        See \fBstandards\fR(5).
493 .SS "ksh93"
498 box;
499 c | c
500 l | l .
501 ATTRIBUTE TYPE  ATTRIBUTE VALUE
503 Interface Stability     See below.
508 The \fBksh93\fR built-in binding to \fB/bin\fR and \fB/usr/bin\fR is Volatile.
509 The built-in interfaces are Uncommitted.
510 .SH SEE ALSO
513 \fBcomm\fR(1), \fBksh93\fR(1), , \fBpcat\fR(1), \fBsort\fR(1),
514 \fBuncompress\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)