1.\" Copyright (c) 1991 Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)uniq.1 6.3 (Berkeley) 04/26/91 7.\" 8.Dd 9.Dt UNIQ 1 10.Os 11.Sh NAME 12.Nm uniq 13.Nd Report or filter out repeated lines in a file. 14.Sh SYNOPSIS 15.Nm uniq 16.Op Fl c | Fl d | Fl u 17.Op Fl f Ar fields 18.Op Fl s Ar chars 19.Oo 20.Ar input_file 21.Op Ar output_file 22.Oc 23.Pp 24Deprecated Version: 25.Pp 26.Nm uniq 27.Op Fl cdu 28.Op Fl Ns Ar n 29.Op Cm \(pl Ns Ar n 30.Oo 31.Ar input_file 32.Op Ar output_file 33.Oc 34.Sh DESCRIPTION 35The 36.Nm uniq 37utility reads an input file or the standard input 38comparing adjacent 39lines, and writes one copy of each input line on the output. 40The second and succeeding copies of repeated adjacent input 41lines are not written. 42Repeated lines in the input are not detected if they are 43not adjacent, so it is important to 44.Xr sort 1 45the files first. 46.Pp 47The following options are available: 48.Bl -tag -width Ds 49.It Fl c 50Precede each output line with a count of the number 51of times the line occurred in the input. For example: 52.Bd -literal -offset indent 53duplicate_count line_number 54.Ed 55.Pp 56where the duplicate count is a blank padded field of 57up to four digits followed by a space. 58.It Fl d 59Suppress the writing of lines that are not repeated 60in the input. 61.It Fl f Ar fields 62Ignore the first fields on each input line when 63doing comparisons, where fields is a positive 64decimal integer. 65A field is a string of non-blank 66characters separated from adjacent fields 67by blanks. 68.It Fl s Ar chars 69Ignore the first chars characters when doing 70comparisons, where chars is a positive decimal 71integer. 72If specified in conjunction with the 73.Fl f 74option, the first chars characters after the first 75fields fields will be ignored. 76.It Fl u 77Suppress the writing of lines that are repeated in 78the input. 79.It Fl Ns Ar n 80(Deprecated; replaced by 81.Fl f ) . 82Ignore the first n 83fields on each input line when doing comparisons, 84where n is a number. 85A field is a string of non-blank 86characters separated from adjacent fields 87by blanks. 88.It Cm \&\(pl Ns Ar n 89(Deprecated; replaced by 90.Fl s ) . 91Ignore the first 92.Ar m 93characters when doing comparisons, where 94.Ar m 95is a 96number. 97.El 98.Pp 99The following operands are available: 100.Bl -tag -width output_filex 101.It Ar input_file 102A pathname of the input file. 103If the 104.Ar input_file 105operand is not specified, the standard input is 106used. 107.It Ar output_file 108A pathname of the output file. 109This name shall 110always be different from 111.Ar input_file. 112If the 113.Ar output_file 114operand is not specified, the standard 115output is used. If 116.Ar output_file 117is created and an error occurs or a sugnal is caught the 118.Ar output_file 119is not removed. 120.El 121.\" .Pp 122.\" The following environment variables affect the execution of 123.\" uniq: 124.\" .Tl Em LC_CTYPE 125.\" The locale for character classification, used to 126.\" determine the characters constituting a blank in 127.\" the current locale. 128.Pp 129The 130.Xr uniq 131utility exits 0 on success, and >0 if an error occurs. 132.Sh STANDARDS 133The 134.Xr uniq 135utility is expected to be 136.St -p1003.2 137compatible. 138