2022-02-14 02:22:51 +00:00
|
|
|
---
|
|
|
|
title: uniq
|
|
|
|
layout: command
|
|
|
|
version: 0.59.0
|
|
|
|
---
|
2019-12-31 04:05:02 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
Return the unique rows.
|
2019-12-31 04:05:02 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
## Signature
|
2019-12-31 04:05:02 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
```> uniq --count --repeated --ignore-case --unique```
|
2019-12-31 04:05:02 +00:00
|
|
|
|
2022-02-14 02:22:51 +00: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 04:05:02 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
Remove duplicate rows of a list/table
|
2020-06-23 18:21:47 +00:00
|
|
|
```shell
|
2022-02-14 02:22:51 +00:00
|
|
|
> [2 3 3 4] | uniq
|
2019-12-31 04:05:02 +00:00
|
|
|
```
|
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
Only print duplicate lines, one for each group
|
2020-06-23 18:21:47 +00:00
|
|
|
```shell
|
2022-02-14 02:22:51 +00:00
|
|
|
> [1 2 2] | uniq -d
|
2019-12-31 04:05:02 +00:00
|
|
|
```
|
2020-06-21 00:22:06 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
Only print unique lines lines
|
|
|
|
```shell
|
|
|
|
> [1 2 2] | uniq -u
|
|
|
|
```
|
2020-06-23 18:21:47 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
Ignore differences in case when comparing
|
|
|
|
```shell
|
|
|
|
> ['hello' 'goodbye' 'Hello'] | uniq -i
|
|
|
|
```
|
2020-06-21 00:22:06 +00:00
|
|
|
|
2022-02-14 02:22:51 +00:00
|
|
|
Remove duplicate rows and show counts of a list/table
|
2020-06-23 18:21:47 +00:00
|
|
|
```shell
|
2022-02-14 02:22:51 +00:00
|
|
|
> [1 2 2] | uniq -c
|
2020-06-23 18:21:47 +00:00
|
|
|
```
|