February 2001
Beginner to intermediate
448 pages
9h 2m
English
Official Description
Removes or lists repeated lines in a file.
Syntax
uniq [-cdu] [-f fields] [-s chars] [input-file [output-file]]
Options
-c displays the count of occurrences of the line.
-d displays repeated lines only.
-f fields ignores specified fields when comparing lines.
-s chars ignores the specified number of chars when doing comparisons.
-u displays unique lines only.
Oddities
Repeated lines must be on consecutive lines to be found.
You can arrange them with the sort command before processing.
Example
$ uniq utest den cheryl cheryl cheryl den mark # Mark shows up once den den cheryl dencheryl den cheryl $ $ uniq -c utest 1 den 1 cheryl 1 cheryl cheryl den 3 mark # There were four lines of mark 1 den 1 den cheryl 1 dencheryl ...
Read now
Unlock full access