2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: uniq
|
|
|
|
layout: command
|
|
|
|
version: 0.59.0
|
|
|
|
---
|
2019-12-31 05:05:02 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Return the unique rows.
|
2019-12-31 05:05:02 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Signature
|
2019-12-31 05:05:02 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
```> uniq --count --repeated --ignore-case --unique```
|
2019-12-31 05:05:02 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Parameters
|
|
|
|
|
|
|
|
- `--count`: Count the unique rows
|
|
|
|
- `--repeated`: Count the rows that has more than one value
|
|
|
|
- `--ignore-case`: Ignore differences in case when comparing
|
|
|
|
- `--unique`: Only return unique values
|
|
|
|
|
|
|
|
## Examples
|
2019-12-31 05:05:02 +01:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Remove duplicate rows of a list/table
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> [2 3 3 4] | uniq
|
2019-12-31 05:05:02 +01:00
|
|
|
```
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Only print duplicate lines, one for each group
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> [1 2 2] | uniq -d
|
2019-12-31 05:05:02 +01:00
|
|
|
```
|
2020-06-21 02:22:06 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Only print unique lines lines
|
|
|
|
```shell
|
|
|
|
> [1 2 2] | uniq -u
|
|
|
|
```
|
2020-06-23 20:21:47 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Ignore differences in case when comparing
|
|
|
|
```shell
|
|
|
|
> ['hello' 'goodbye' 'Hello'] | uniq -i
|
|
|
|
```
|
2020-06-21 02:22:06 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Remove duplicate rows and show counts of a list/table
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> [1 2 2] | uniq -c
|
2020-06-23 20:21:47 +02:00
|
|
|
```
|