uniq filename [option]*
uniq stuff uniq /frodo_baggin -u uniq other +u
UNIQ examines a file for duplicate lines. Duplicate lines are only detected if they are consecutive. For example, consider a file "sample" containing
b a a b c
The output of
uniq sample
would be
b a b c
The output of UNIQ consists of the lines in the file with duplicate lines removed. As shown above, UNIQ does not consider the "b" lines to be duplicate because they aren't adjacent. The output of
uniq sample +unique
is
b b c
because these are the lines that had no duplicates. The output of
uniq sample -unique
is just
a
If you want to remove the duplicate lines from a file, redirect the output of UNIQ to a temporary file, then copy the temporary file back, as in
uniq sample >tmp copy tmp sample
Commands of the following form do NOT work:
uniq sample >sample
UNIQ truncates lines of length longer than 1023 characters.
Copyright © 1996, Thinkage Ltd.