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