NAME
uniq - Removes or lists repeated lines in a file
SYNOPSIS
uniq [-c | -d | -u] [-f fields] [-s characters] [+number]
[-number] [input_file] [output_file]
The uniq command reads standard input by default, or
input_file, compares adjacent lines, removes the second and
succeeding occurrences of a line, and writes to standard
output or the specified file output_file.
FLAGS
-c Precedes each output line with a count of the number of
times each line appears in the file. This flag super-
sedes -d and -u.
-d Displays repeated lines only.
-f fields
Ignores the first fields fields on each input line when
doing comparisons, where fields is a positive decimal
integer. A field is the maximal string matched by the
basic regular expression:
[[:blank:]]*[^[:blank:]]*
If the fields argument specifies more fields than appear
on an input line, a null string is used for comparisons.
-s characters
Ignores the specified number of characters when doing
comparisons. The characters argument is a positive
decimal integer.
If specified with the -f flag, the first characters
characters after the first fields fields are ignored.
If the characters argument specifies more characters
than remain on an input line, uniq uses a null string
for comparison.
-u Displays unique lines only.
-number
Skips over the first number-1 fields. A field is a
string of nonspace, nontab characters separated by tabs
or spaces, or both, from adjacent data on the same line.
Equivalent to -f fields. (Obsolescent)
+number
Skips over the first number-1 characters. Fields speci-
fied by number are skipped before characters.
Equivalent to -s characters. (Obsolescent)
DESCRIPTION
The input_file and output_file arguments must specify dif-
ferent files.
Repeated lines must be on consecutive lines to be found.
You can arrange them with the sort command before process-
ing.
EXAMPLES
To delete repeated lines in the following file called fruit
and save it to a file named newfruit, enter:
uniq fruit newfruit
The file fruit contains the following lines:
apples
apples
bananas
cherries
cherries
peaches
pears
The file newfruit contains the following lines:
apples
peaches
pears
bananas
cherries
RELATED INFORMATION
Commands: comm(1), sort(1).
Acknowledgement and Disclaimer