'\" te .\" Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" 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 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. This notice shall appear on any product containing this material. .TH uniq 1 "28 Jul 2011" "SunOS 5.11" "User Commands" .SH NAME uniq \- report or filter out repeated lines in a file .SH SYNOPSIS .LP .nf \fB/usr/bin/uniq\fR [\fB-c\fR | \fB -d \fR | \fB -u \fR] [\fB -f \fR \fIfields\fR] [\fB-s\fR \fIchar\fR] [\fIinput_file\fR [\fIoutput_file\fR]] .fi .LP .nf \fB/usr/bin/uniq\fR [\fB-c\fR | \fB -d \fR | \fB -u \fR] [\fB-\fR\fIn\fR ] [\fB+\fR\fIm\fR ] [\fIinput_file\fR [\fIoutput_file\fR]] .fi .SH DESCRIPTION .sp .LP \fBuniq\fR 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. .sp .LP If the output file, \fIoutput_file\fR, is not specified, \fBuniq\fR writes to standard output. If no \fIinput_file\fR is given, or if the \fIinput_file\fR is \fB-\fR, \fBuniq\fR reads from standard input with the start of the file is defined as the current offset. .SH OPTIONS .sp .LP The following options are supported: .sp .ne 2 .mk .na \fB\fB-c\fR\fR .ad .RS 6n .rt Precedes each output line with a count of the number of times the line occurred in the input. .RE .sp .ne 2 .mk .na \fB\fB-d\fR\fR .ad .RS 6n .rt Suppresses the writing of lines that are not repeated in the input. .RE .sp .ne 2 .mk .na \fB\fB-f\fR\fR .ad .br .na \fB\fR .ad .RS 6n .rt Ignores the first \fIfields\fR \fIfields\fR on each input line when doing comparisons, where \fIfields\fR is a positive decimal integer. A \fIfield\fR is the maximal string matched by the basic regular expression: .sp .in +2 .nf [[:blank:]]*[^[:blank:]]* .fi .in -2 .sp If \fIfields\fR specifies more \fIfields\fR than appear on an input line, a null string are used for comparison. .RE .sp .ne 2 .mk .na \fB\fB-s\fR\fR .ad .RS 6n .rt Ignores the first chars characters when doing comparisons, where chars is a positive decimal integer. If specified in conjunction with the \fB-f\fR option, the first chars characters after the first \fIfields\fR \fIfields\fR are ignored. If chars specifies more characters than remain on an input line, a null string are used for comparison. .RE .sp .ne 2 .mk .na \fB\fB-u\fR\fR .ad .RS 6n .rt Suppresses the writing of lines that are repeated in the input. .RE .sp .ne 2 .mk .na \fB\fB-\fR\fIn\fR\fR .ad .RS 6n .rt Equivalent to \fB-f\fR \fIfields\fR with \fIfields\fR set to \fIn\fR. .RE .sp .ne 2 .mk .na \fB\fB+\fR\fIm\fR\fR .ad .RS 6n .rt Equivalent to \fB-s\fR \fIchars\fR with \fIchars\fR set to \fIm\fR. .RE .SH OPERANDS .sp .LP The following operands are supported: .sp .ne 2 .mk .na \fB\fIinput_file\fR\fR .ad .RS 15n .rt A path name of the input file. If \fIinput_file\fR is not specified, or if the \fIinput_file\fR is \fB\(mi\fR, the standard input is used. .RE .sp .ne 2 .mk .na \fB\fIoutput_file\fR\fR .ad .RS 15n .rt A path name of the output file. If \fIoutput_file\fR is not specified, the standard output is used. The results are unspecified if the file named by \fIoutput_file\fR is the file named by \fIinput_file\fR. .RE .SH EXAMPLES .LP \fBExample 1 \fRUsing the \fBuniq\fR Command .sp .LP The following example lists the contents of the \fBuniq.test\fR file and outputs a copy of the repeated lines. .sp .in +2 .nf example% \fBcat uniq.test\fR This is a test. This is a test. TEST. Computer. TEST. TEST. Software. example% \fBuniq -d uniq.test\fR This is a test. TEST. example% .fi .in -2 .sp .sp .LP The next example outputs just those lines that are not repeated in the \fBuniq.test\fR file. .sp .in +2 .nf example% \fBuniq -u uniq.test\fR TEST. Computer. Software. example% .fi .in -2 .sp .sp .LP The last example outputs a report with each line preceded by a count of the number of times each line occurred in the file: .sp .in +2 .nf example% \fBuniq -c uniq.test\fR 2 This is a test. 1 TEST. 1 Computer. 2 TEST. 1 Software. example% .fi .in -2 .sp .SH ENVIRONMENT VARIABLES .sp .LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBuniq\fR: \fBLANG\fR, \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. .SH EXIT STATUS .sp .LP The following exit values are returned: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt Successful completion. .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt An error occurred. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Availabilitysystem/core-os _ CSIEnabled _ Interface StabilityCommitted _ StandardSee \fBstandards\fR(5). .TE .SH SEE ALSO .sp .LP \fBcomm\fR(1), \fBpack\fR(1), \fBpcat\fR(1), \fBsort\fR(1), \fBuncompress\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)