mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-09-04 12:53:25 +02:00

This involves another command, but it's such a natural extension of uniq's `-c` functionality that I feel it's warranted to show here. We should probably add a sort to the -c example too, because uniq only deals with *sequential* line repetitions.
23 lines
404 B
Markdown
23 lines
404 B
Markdown
# uniq
|
|
|
|
> Output the unique lines from the given input or file.
|
|
|
|
- Display each line once:
|
|
|
|
`uniq {{file}}`
|
|
|
|
- Display only unique lines:
|
|
|
|
`uniq -u {{file}}`
|
|
|
|
- Display only duplicate lines:
|
|
|
|
`uniq -d {{file}}`
|
|
|
|
- Display number of occurences of each line along with that line:
|
|
|
|
`uniq -c {{file}}`
|
|
|
|
- Display number of occurences of each line, sorted by the most frequent:
|
|
|
|
`uniq -c {{file}} | sort -nr`
|