1.\" $NetBSD: uniq.1,v 1.13 2012/08/26 14:13:50 wiz Exp $ 2.\" 3.\" Copyright (c) 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" This code is derived from software contributed to Berkeley by 7.\" the Institute of Electrical and Electronics Engineers, Inc. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. Neither the name of the University nor the names of its contributors 18.\" may be used to endorse or promote products derived from this software 19.\" without specific prior written permission. 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" SUCH DAMAGE. 32.\" 33.\" @(#)uniq.1 8.1 (Berkeley) 6/6/93 34.\" 35.Dd August 26, 2012 36.Dt UNIQ 1 37.Os 38.Sh NAME 39.Nm uniq 40.Nd report or filter out repeated lines in a file 41.Sh SYNOPSIS 42.Nm 43.Op Fl cdu 44.Op Fl f Ar fields 45.Op Fl s Ar chars 46.Oo 47.Ar input_file 48.Op Ar output_file 49.Oc 50.Sh DESCRIPTION 51The 52.Nm 53utility reads the standard input comparing adjacent lines, and writes 54a copy of each unique input line to the standard output. 55The second and succeeding copies of identical adjacent input lines are 56not written. 57Repeated lines in the input will not be detected if they are not adjacent, 58so it may be necessary to sort the files first. 59.Pp 60The following options are available: 61.Bl -tag -width Ds 62.It Fl c 63Precede each output line with the count of the number of times the line 64occurred in the input, followed by a single space. 65.It Fl d 66Don't output lines that are not repeated in the input. 67.It Fl f Ar fields 68Ignore the first 69.Ar fields 70in each input line when doing comparisons. 71A field is a string of non-blank characters separated from adjacent fields 72by blanks. 73Field numbers are one based, i.e., the first field is field one. 74.It Fl s Ar chars 75Ignore the first 76.Ar chars 77characters in each input line when doing comparisons. 78If specified in conjunction with the 79.Fl f 80option, the first 81.Ar chars 82characters after the first 83.Ar fields 84fields will be ignored. 85Character numbers are one based, i.e., the first character is character one. 86.It Fl u 87Don't output lines that are repeated in the input. 88.\".It Fl Ns Ar n 89.\"(Deprecated; replaced by 90.\".Fl f ) . 91.\"Ignore the first n 92.\"fields on each input line when doing comparisons, 93.\"where n is a number. 94.\"A field is a string of non-blank 95.\"characters separated from adjacent fields 96.\"by blanks. 97.\".It Cm \&\(pl Ns Ar n 98.\"(Deprecated; replaced by 99.\".Fl s ) . 100.\"Ignore the first 101.\".Ar m 102.\"characters when doing comparisons, where 103.\".Ar m 104.\"is a 105.\"number. 106.El 107.Pp 108Additional arguments 109.Ar input_file 110and 111.Ar output_file 112may be specified on the command line, 113where the former is then used as the name of an input file, 114and the latter as the name of an output file. 115.Sh EXIT STATUS 116.Ex -std 117.Sh COMPATIBILITY 118The historic 119.Cm \&\(pl Ns Ar number 120and 121.Fl Ns Ar number 122options have been deprecated but are still supported in this implementation. 123.Sh SEE ALSO 124.Xr sort 1 125.Sh STANDARDS 126The 127.Nm 128utility is expected to be 129.St -p1003.2 130compatible. 131