1.\" Copyright (c) 1991 Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the Institute of Electrical and Electronics Engineers, Inc. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)uniq.1 6.4 (Berkeley) 6/27/91 36.\" 37.Dd June 27, 1991 38.Dt UNIQ 39.Os 40.Sh NAME 41.Nm uniq 42.Nd Report or filter out repeated lines in a file. 43.Sh SYNOPSIS 44.Nm uniq 45.Op Fl c | Fl d | Fl u 46.Op Fl f Ar fields 47.Op Fl s Ar chars 48.Oo 49.Ar input_file 50.Op Ar output_file 51.Oc 52.Pp 53Deprecated Version: 54.Pp 55.Nm uniq 56.Op Fl cdu 57.Op Fl Ns Ar n 58.Op Cm \(pl Ns Ar n 59.Oo 60.Ar input_file 61.Op Ar output_file 62.Oc 63.Sh DESCRIPTION 64The 65.Nm uniq 66utility reads an input file or the standard input 67comparing adjacent 68lines, and writes one copy of each input line on the output. 69The second and succeeding copies of repeated adjacent input 70lines are not written. 71Repeated lines in the input are not detected if they are 72not adjacent, so it is important to 73.Xr sort 1 74the files first. 75.Pp 76The following options are available: 77.Bl -tag -width Ds 78.It Fl c 79Precede each output line with a count of the number 80of times the line occurred in the input. For example: 81.Bd -literal -offset indent 82duplicate_count line_number 83.Ed 84.Pp 85where the duplicate count is a blank padded field of 86up to four digits followed by a space. 87.It Fl d 88Suppress the writing of lines that are not repeated 89in the input. 90.It Fl f Ar fields 91Ignore the first fields on each input line when 92doing comparisons, where fields is a positive 93decimal integer. 94A field is a string of non-blank 95characters separated from adjacent fields 96by blanks. 97.It Fl s Ar chars 98Ignore the first chars characters when doing 99comparisons, where chars is a positive decimal 100integer. 101If specified in conjunction with the 102.Fl f 103option, the first chars characters after the first 104fields fields will be ignored. 105.It Fl u 106Suppress the writing of lines that are repeated in 107the input. 108.It Fl Ns Ar n 109(Deprecated; replaced by 110.Fl f ) . 111Ignore the first n 112fields on each input line when doing comparisons, 113where n is a number. 114A field is a string of non-blank 115characters separated from adjacent fields 116by blanks. 117.It Cm \&\(pl Ns Ar n 118(Deprecated; replaced by 119.Fl s ) . 120Ignore the first 121.Ar m 122characters when doing comparisons, where 123.Ar m 124is a 125number. 126.El 127.Pp 128The following operands are available: 129.Bl -tag -width output_filex 130.It Ar input_file 131A pathname of the input file. 132If the 133.Ar input_file 134operand is not specified, the standard input is 135used. 136.It Ar output_file 137A pathname of the output file. 138This name shall 139always be different from 140.Ar input_file. 141If the 142.Ar output_file 143operand is not specified, the standard 144output is used. If 145.Ar output_file 146is created and an error occurs or a sugnal is caught the 147.Ar output_file 148is not removed. 149.El 150.\" .Pp 151.\" The following environment variables affect the execution of 152.\" uniq: 153.\" .Tl Em LC_CTYPE 154.\" The locale for character classification, used to 155.\" determine the characters constituting a blank in 156.\" the current locale. 157.Pp 158The 159.Xr uniq 160utility exits 0 on success, and >0 if an error occurs. 161.Sh STANDARDS 162The 163.Xr uniq 164utility is expected to be 165.St -p1003.2 166compatible. 167