2016-01-12 18:08:52 +03:00
|
|
|
# uniq
|
|
|
|
|
2015-12-29 16:00:40 +03:00
|
|
|
> Output the unique lines from the given input or file.
|
2016-07-15 14:18:37 +03:00
|
|
|
> Since it does not detect repeated lines unless they are adjacent, we need to sort them first.
|
2016-01-12 18:08:52 +03:00
|
|
|
|
|
|
|
- Display each line once:
|
|
|
|
|
2016-07-15 14:18:37 +03:00
|
|
|
`sort {{file}} | uniq`
|
2016-01-12 18:08:52 +03:00
|
|
|
|
|
|
|
- Display only unique lines:
|
|
|
|
|
2016-07-15 14:18:37 +03:00
|
|
|
`sort {{file}} | uniq -u`
|
2016-01-12 18:08:52 +03:00
|
|
|
|
|
|
|
- Display only duplicate lines:
|
|
|
|
|
2016-07-15 14:18:37 +03:00
|
|
|
`sort {{file}} | uniq -d`
|
2016-01-12 18:08:52 +03:00
|
|
|
|
|
|
|
- Display number of occurences of each line along with that line:
|
|
|
|
|
2016-07-15 14:18:37 +03:00
|
|
|
`sort {{file}} | uniq -c`
|
2016-07-10 12:26:13 +03:00
|
|
|
|
|
|
|
- Display number of occurences of each line, sorted by the most frequent:
|
|
|
|
|
2016-07-15 14:18:37 +03:00
|
|
|
`sort {{file}} | uniq -c | sort -nr`
|