xref: /netbsd-src/usr.bin/uniq/uniq.1 (revision a5847cc334d9a7029f6352b847e9e8d71a0f9e0c)
1.\"	$NetBSD: uniq.1,v 1.12 2010/10/06 06:43:26 dholland 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 January 6, 2007
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
108If additional arguments are specified on the command line, the first
109such argument is used as the name of an input file, the second is used
110as the name of an output file.
111.Pp
112The
113.Nm
114utility exits 0 on success, and \*[Gt]0 if an error occurs.
115.Sh COMPATIBILITY
116The historic
117.Cm \&\(pl Ns Ar number
118and
119.Fl Ns Ar number
120options have been deprecated but are still supported in this implementation.
121.Sh SEE ALSO
122.Xr sort 1
123.Sh STANDARDS
124The
125.Nm
126utility is expected to be
127.St -p1003.2
128compatible.
129