uniq—reports on duplicate lines in a file
uniq [ [ –u ] [ –d ] [ –c ] [ +n ] [ –n ] ] [ input [ output ] ]
uniq reads the input file, comparing adjacent lines. In the normal case, the second and succeeding copies of repeated lines are removed; the remainder is written on the output file. Input and output should always be different.
Example A.67.
1 uniq file1 file2
2 uniq -d -2 file3
EXPLANATION
Removes duplicate adjacent lines from file1 and puts output in file2. Displays the duplicate lines where the duplicate starts at third field.
|