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/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
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.
25 .\" This notice shall appear on any product containing this material.
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.
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.
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]
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
48 .TH UNIQ 1 "Mar 13, 2008"
50 uniq \- report or filter out repeated lines in a file
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]]
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]]
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]]
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]]
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.
85 Repeated lines in the input are not detected if they are not adjacent.
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.
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.
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
108 The following options are supported by \fB/usr/bin/uniq\fR:
115 Precedes each output line with a count of the number of times the line occurred
125 Suppresses the writing of lines that are not repeated in the input.
131 \fB\fB-f\fR \fIfields\fR\fR
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:
140 [[:blank:]]*[^[:blank:]]*
145 If \fIfields\fR specifies more fields than appear on an input line, a null
146 string is used for comparison.
155 Equivalent to \fB-s\fR \fIchars\fR with \fIchars\fR set to \fIm\fR.
161 \fB\fB\(mi\fR\fIn\fR\fR
164 Equivalent to \fB-f\fR \fIfields\fR with \fIfields\fR set to \fIn\fR.
170 \fB\fB-s\fR \fIchars\fR\fR
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.
186 Suppresses the writing of lines that are repeated in the input.
192 The following options are supported by the \fBuniq\fR built-in command is
204 Outputs the number of times each line occurred along with the line.
214 \fB\fB--repeated | duplicates\fR\fR
217 Outputs only duplicate lines.
227 \fB\fB--all-repeated\fR[\fB=\fR\fIdelimit\fR]\fR
230 Outputs all duplicate lines as a group with an empty line delimiter specified
233 Specify \fIdelimit\fR as one of the following:
240 Do not delimit duplicate groups.
249 Prepend an empty line before each group.
258 Separate each group with an empty line.
261 The value for \fIdelimit\fR can be omitted. The default value is \fBnone\fR.
271 \fB\fB--skip-fields=\fR\fIfields\fR\fR
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.
286 \fB\fB--ignore-case\fR\fR
289 Ignore case in comparisons.
298 Equivalent to the \fB-s\fR \fIchars\fR option, with \fIchars\fR set to \fIm\fR.
307 Equivalent to the \fB-f\fR \fIfields\fR option, with \fIfields\fR set to
318 \fB\fB--skip-chars=\fR\fIchars\fR\fR
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.
338 Outputs unique lines.
348 \fB\fB--check-chars=\fR\fIchars\fR\fR
351 Skips over any specified fields and characters, then compares \fIchars\fR
352 number of characters.
358 The following operands are supported:
362 \fB\fIinput_file\fR\fR
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.
372 \fB\fIoutput_file\fR\fR
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.
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.
391 example% \fBcat uniq.test\fR
400 example% \fBuniq -d uniq.test\fR
410 The next example outputs just those lines that are not repeated in the
411 \fBuniq.test\fR file.
416 example% \fBuniq -u uniq.test\fR
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:
433 example% \fBuniq -c uniq.test\fR
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.
453 The following exit values are returned:
460 Successful completion.
475 See \fBattributes\fR(5) for descriptions of the following attributes:
484 ATTRIBUTE TYPE ATTRIBUTE VALUE
488 Interface Stability Committed
490 Standard See \fBstandards\fR(5).
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.
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)