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
http://www.opengroup.org/bookstore/.
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 SunOS 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.
This notice shall appear on any product containing this material.
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.
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.
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]
Copyright 1989 AT&T
Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
/usr/bin/uniq [-c | -d | -u] [-f fields] [-s char] [input_file [output_file]]
/usr/bin/uniq [-c | -d | -u] [-n] [+ m] [input_file [output_file]]
uniq [-cdiu] [-D[delimit]] [-f fields] [-s chars] [-w chars] [input_file [output_file]]
uniq [-cdiu] [-D[delimit]] [-n] [+m] [-w chars] [input_file [output_file]]
Repeated lines in the input are not detected if they are not adjacent.
uniq reads an input, comparing adjacent lines, and writing one copy of each input line on the output. The second and succeeding copies of the repeated adjacent lines are not written.
If output_file is not specified, uniq writes to standard output. If input_file is not specified, or if input_file is -, uniq reads from standard input, and the start of the file is defined as the current offset.
Precedes each output line with a count of the number of times the line occurred in the input.
Suppresses the writing of lines that are not repeated in the input.
Ignores the first fields fields on each input line when doing comparisons, where fields is a positive decimal integer. A field is the maximal string matched by the basic regular expression:
[[:blank:]]*[^[:blank:]]*If fields specifies more fields than appear on an input line, a null string is used for comparison.
Equivalent to -s chars with chars set to m.
Equivalent to -f fields with fields set to n.
Ignores the first chars characters when doing comparisons, where chars is a positive decimal integer. If specified in conjunction with the -f option, the first chars characters after the first fields fields is ignored. If chars specifies more characters than remain on an input line, a null string is used for comparison.
Suppresses the writing of lines that are repeated in the input.
--count
Outputs the number of times each line occurred along with the line.
--repeated | duplicates
Outputs only duplicate lines.
--all-repeated[=delimit]
Outputs all duplicate lines as a group with an empty line delimiter specified by delimit. Specify delimit as one of the following: none
Do not delimit duplicate groups.
Prepend an empty line before each group.
Separate each group with an empty line.
--skip-fields=fields
Skips over fields number of fields before checking for uniqueness. A field is the minimal string matching the BRE [[:blank:]]*[^[:blank:]]*.
--ignore-case
Ignore case in comparisons.
Equivalent to the -s chars option, with chars set to m.
Equivalent to the -f fields option, with fields set to n.
--skip-chars=chars
Skips over chars number of characters before checking for uniqueness. If specified with the -f option, the first chars after the first fields are ignored. If the chars specifies more characters than are on the line, an empty string is used for comparison.
--uniq
Outputs unique lines.
--check-chars=chars
Skips over any specified fields and characters, then compares chars number of characters.
A path name of the input file. If input_file is not specified, or if the input_file is -, the standard input is used.
A path name of the output file. If output_file is not specified, the standard output is used. The results are unspecified if the file named by output_file is the file named by input_file.
The following example lists the contents of the uniq.test file and outputs a copy of the repeated lines.
example% cat uniq.test This is a test. This is a test. TEST. Computer. TEST. TEST. Software. example% uniq -d uniq.test This is a test. TEST. example%
The next example outputs just those lines that are not repeated in the uniq.test file.
example% uniq -u uniq.test
TEST.
Computer.
Software.
example%
The last example outputs a report with each line preceded by a count of the number of times each line occurred in the file:
example% uniq -c uniq.test
2 This is a test.
1 TEST.
1 Computer.
2 TEST.
1 Software.
example%
Successful completion.
An error occurred.
ATTRIBUTE TYPE ATTRIBUTE VALUE |
CSI Enabled |
Interface Stability Committed |
Standard See standards(5). |
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Interface Stability See below. |
The ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-in interfaces are Uncommitted.