2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
3 .\" Copyright 1989 AT&T
4 .\" Copyright (c) 2007 Sun Microsystems, Inc. - All Rights Reserved.
5 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
6 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
7 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
8 .\" http://www.opengroup.org/bookstore/.
9 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
10 .\" This notice shall appear on any product containing this material.
11 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
12 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
13 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
14 .TH UNIQ 1 "Mar 13, 2008"
16 uniq \- report or filter out repeated lines in a file
21 \fB/usr/bin/uniq\fR [\fB-c\fR | \fB-d\fR | \fB-u\fR] [\fB-f\fR \fIfields\fR] [\fB-s\fR \fIchar\fR]
22 [\fIinput_file\fR [\fIoutput_file\fR]]
27 \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]]
33 \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]
34 [\fIinput_file\fR [\fIoutput_file\fR]]
39 \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]]
46 The \fBuniq\fR utility reads an input file comparing adjacent lines and writes
47 one copy of each input line on the output. The second and succeeding copies of
48 repeated adjacent input lines are not written.
51 Repeated lines in the input are not detected if they are not adjacent.
55 The \fBuniq\fR built-in in \fBksh93\fR is associated with the \fB/bin\fR or
56 \fB/usr/bin path\fR. It is invoked when \fBuniq\fR is executed without a
57 pathname prefix and the pathname search finds a \fB/bin/uniq\fR or
58 \fB/usr/bin/uniq\fR executable.
61 \fBuniq\fR reads an input, comparing adjacent lines, and writing one copy of
62 each input line on the output. The second and succeeding copies of the repeated
63 adjacent lines are not written.
66 If \fIoutput_file\fR is not specified, \fBuniq\fR writes to standard output. If
67 \fIinput_file\fR is not specified, or if \fIinput_file\fR is \fB-\fR,
68 \fBuniq\fR reads from standard input, and the start of the file is defined as
74 The following options are supported by \fB/usr/bin/uniq\fR:
81 Precedes each output line with a count of the number of times the line occurred
91 Suppresses the writing of lines that are not repeated in the input.
97 \fB\fB-f\fR \fIfields\fR\fR
100 Ignores the first \fIfields\fR fields on each input line when doing
101 comparisons, where \fIfields\fR is a positive decimal integer. A field is the
102 maximal string matched by the basic regular expression:
106 [[:blank:]]*[^[:blank:]]*
111 If \fIfields\fR specifies more fields than appear on an input line, a null
112 string is used for comparison.
121 Equivalent to \fB-s\fR \fIchars\fR with \fIchars\fR set to \fIm\fR.
127 \fB\fB\(mi\fR\fIn\fR\fR
130 Equivalent to \fB-f\fR \fIfields\fR with \fIfields\fR set to \fIn\fR.
136 \fB\fB-s\fR \fIchars\fR\fR
139 Ignores the first \fIchars\fR characters when doing comparisons, where
140 \fIchars\fR is a positive decimal integer. If specified in conjunction with the
141 \fB-f\fR option, the first \fIchars\fR characters after the first \fIfields\fR
142 fields is ignored. If \fIchars\fR specifies more characters than remain on an
143 input line, a null string is used for comparison.
152 Suppresses the writing of lines that are repeated in the input.
158 The following options are supported by the \fBuniq\fR built-in command is
170 Outputs the number of times each line occurred along with the line.
180 \fB\fB--repeated | duplicates\fR\fR
183 Outputs only duplicate lines.
193 \fB\fB--all-repeated\fR[\fB=\fR\fIdelimit\fR]\fR
196 Outputs all duplicate lines as a group with an empty line delimiter specified
199 Specify \fIdelimit\fR as one of the following:
206 Do not delimit duplicate groups.
215 Prepend an empty line before each group.
224 Separate each group with an empty line.
227 The value for \fIdelimit\fR can be omitted. The default value is \fBnone\fR.
237 \fB\fB--skip-fields=\fR\fIfields\fR\fR
240 Skips over \fIfields\fR number of fields before checking for uniqueness. A
241 field is the minimal string matching the \fBBRE
242 [[:\fR\fIblank\fR\fB:]]*[^[:\fR\fIblank\fR\fB:]]*\fR.
252 \fB\fB--ignore-case\fR\fR
255 Ignore case in comparisons.
264 Equivalent to the \fB-s\fR \fIchars\fR option, with \fIchars\fR set to \fIm\fR.
273 Equivalent to the \fB-f\fR \fIfields\fR option, with \fIfields\fR set to
284 \fB\fB--skip-chars=\fR\fIchars\fR\fR
287 Skips over \fIchars\fR number of characters before checking for uniqueness.
289 If specified with the \fB-f\fR option, the first \fIchars\fR after the first
290 fields are ignored. If the \fIchars\fR specifies more characters than are on
291 the line, an empty string is used for comparison.
304 Outputs unique lines.
314 \fB\fB--check-chars=\fR\fIchars\fR\fR
317 Skips over any specified fields and characters, then compares \fIchars\fR
318 number of characters.
324 The following operands are supported:
328 \fB\fIinput_file\fR\fR
331 A path name of the input file. If \fIinput_file\fR is not specified, or if the
332 \fIinput_file\fR is \fB\(mi\fR, the standard input is used.
338 \fB\fIoutput_file\fR\fR
341 A path name of the output file. If \fIoutput_file\fR is not specified, the
342 standard output is used. The results are unspecified if the file named by
343 \fIoutput_file\fR is the file named by \fIinput_file\fR.
348 \fBExample 1 \fRUsing the \fBuniq\fR Command
351 The following example lists the contents of the \fBuniq.test\fR file and
352 outputs a copy of the repeated lines.
357 example% \fBcat uniq.test\fR
366 example% \fBuniq -d uniq.test\fR
376 The next example outputs just those lines that are not repeated in the
377 \fBuniq.test\fR file.
382 example% \fBuniq -u uniq.test\fR
393 The last example outputs a report with each line preceded by a count of the
394 number of times each line occurred in the file:
399 example% \fBuniq -c uniq.test\fR
410 .SH ENVIRONMENT VARIABLES
413 See \fBenviron\fR(5) for descriptions of the following environment variables
414 that affect the execution of \fBuniq\fR: \fBLANG\fR, \fBLC_ALL\fR,
415 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
419 The following exit values are returned:
426 Successful completion.
441 See \fBattributes\fR(5) for descriptions of the following attributes:
450 ATTRIBUTE TYPE ATTRIBUTE VALUE
454 Interface Stability Committed
456 Standard See \fBstandards\fR(5).
467 ATTRIBUTE TYPE ATTRIBUTE VALUE
469 Interface Stability See below.
474 The \fBksh93\fR built-in binding to \fB/bin\fR and \fB/usr/bin\fR is Volatile.
475 The built-in interfaces are Uncommitted.
479 \fBcomm\fR(1), \fBksh93\fR(1), , \fBpcat\fR(1), \fBsort\fR(1),
480 \fBuncompress\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)