Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)
uniq(1) OSS Shell and Utilities Reference Manual
NAME
uniq - Removes or lists repeated lines in a file
SYNOPSIS
Current syntax
uniq [-c | -d | -u][-f fields][-s characters][input_file][output_file]
Obsolescent syntax
uniq [-c | -d | -u][-number][+number][input_file][output_file]
The uniq command reads standard input by default or, the specified 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 supersedes -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 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 characters. Fields specified by number are skipped before
characters. Equivalent to -s characters. (Obsolescent)
DESCRIPTION
The input_file and output_file arguments must specify different files.
Repeated lines must be on consecutive lines to be found. You can arrange them with the sort
command before processing.
9−34 Hewlett-Packard Company 527188-021