xref: /original-bsd/usr.bin/uniq/uniq.1 (revision dc4562f1)
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.\" %sccs.include.redist.roff%
8.\"
9.\"     @(#)uniq.1	6.5 (Berkeley) 01/09/92
10.\"
11.Dd
12.Dt UNIQ 1
13.Os
14.Sh NAME
15.Nm uniq
16.Nd report or filter out repeated lines in a file
17.Sh SYNOPSIS
18.Nm uniq
19.Op Fl c | Fl d | Fl u
20.Op Fl f Ar fields
21.Op Fl s Ar chars
22.Oo
23.Ar input_file
24.Op Ar output_file
25.Oc
26.Sh DESCRIPTION
27The
28.Nm uniq
29utility reads the standard input comparing adjacent lines, and writes
30a copy of each unique input line to the standard output.
31The second and succeeding copies of identical adjacent input lines are
32not written.
33Repeated lines in the input will not be detected if they are not adjacent,
34so it may be necessary to sort the files first.
35.Pp
36The following options are available:
37.Bl -tag -width Ds
38.It Fl c
39Precede each output line with the count of the number of times the line
40occurred in the input, followed by a single space.
41.It Fl d
42Don't output lines that are not repeated in the input.
43.It Fl f Ar fields
44Ignore the first
45.Ar fields
46in each input line when doing comparisons.
47A field is a string of non-blank characters separated from adjacent fields
48by blanks.
49Field numbers are one based, i.e. the first field is field one.
50.It Fl s Ar chars
51Ignore the first
52.Ar chars
53characters in each input line when doing comparisons.
54If specified in conjunction with the
55.Fl f
56option, the first
57.Ar chars
58characters after the first
59.Ar fields
60fields will be ignored.
61Character numbers are one based, i.e. the first character is character one.
62.It Fl u
63Don't output lines that are repeated in the input.
64.\".It Fl Ns Ar n
65.\"(Deprecated; replaced by
66.\".Fl f ) .
67.\"Ignore the first n
68.\"fields on each input line when doing comparisons,
69.\"where n is a number.
70.\"A field is a string of non-blank
71.\"characters separated from adjacent fields
72.\"by blanks.
73.\".It Cm \&\(pl Ns Ar n
74.\"(Deprecated; replaced by
75.\".Fl s ) .
76.\"Ignore the first
77.\".Ar m
78.\"characters when doing comparisons, where
79.\".Ar m
80.\"is a
81.\"number.
82.El
83.Pp
84If additional arguments are specified on the command line, the first
85such argument is used as the name of an input file, the second is used
86as the name of an output file.
87.Pp
88The
89.Nm uniq
90utility exits 0 on success, and >0 if an error occurs.
91.Sh COMPATIBILITY
92The historic
93.Cm \&\(pl Ns Ar number
94and
95.Fl Ns Ar number
96options have been deprecated but are still supported in this implementation.
97.Sh SEE ALSO
98.Xr sort 1
99.Sh STANDARDS
100The
101.Nm uniq
102utility is expected to be
103.St -p1003.2
104compatible.
105