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

26 lines
604 B
Markdown
Raw Normal View History

2016-01-12 10:08:52 -05:00
# 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.
> More information: <https://www.gnu.org/software/coreutils/uniq>.
2016-01-12 10:08:52 -05:00
- Display each line once:
`sort {{file}} | uniq`
2016-01-12 10:08:52 -05:00
- Display only unique lines:
`sort {{file}} | uniq -u`
2016-01-12 10:08:52 -05:00
- Display only duplicate lines:
`sort {{file}} | uniq -d`
2016-01-12 10:08:52 -05:00
2017-05-12 11:29:18 +02:00
- Display number of occurrences of each line along with that line:
2016-01-12 10:08:52 -05:00
`sort {{file}} | uniq -c`
2017-05-12 11:29:18 +02:00
- Display number of occurrences of each line, sorted by the most frequent:
`sort {{file}} | uniq -c | sort -nr`