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