1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-23 14:02:08 +02:00
tldr/pages/common/uniq.md
K.B.Dharun Krishna 898f711019
pages/*: update GNU coreutils links, sync translation pages (#15543)
Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
2025-01-18 18:45:33 +05:30

25 lines
669 B
Markdown

# uniq
> Output the unique lines from a 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/manual/html_node/uniq-invocation.html>.
- Display each line once:
`sort {{path/to/file}} | uniq`
- Display only unique lines:
`sort {{path/to/file}} | uniq -u`
- Display only duplicate lines:
`sort {{path/to/file}} | uniq -d`
- Display number of occurrences of each line along with that line:
`sort {{path/to/file}} | uniq -c`
- Display number of occurrences of each line, sorted by the most frequent:
`sort {{path/to/file}} | uniq -c | sort -nr`