1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/uniq.md
Alfred Bez 8336898ea9 sort uniq first (#954)
'uniq' does not detect repeated lines unless they are adjacent, so we need to sort them
2016-07-15 13:18:37 +02:00

24 lines
535 B
Markdown

# uniq
> Output the unique lines from the given input or file.
> Since it does not detect repeated lines unless they are adjacent, we need to sort them first.
- Display each line once:
`sort {{file}} | uniq`
- Display only unique lines:
`sort {{file}} | uniq -u`
- Display only duplicate lines:
`sort {{file}} | uniq -d`
- Display number of occurences of each line along with that line:
`sort {{file}} | uniq -c`
- Display number of occurences of each line, sorted by the most frequent:
`sort {{file}} | uniq -c | sort -nr`