uniq
Collapse adjacent duplicate lines, optionally counting occurrences or showing only unique/duplicate lines. Combine with 'sort' for full deduplication.
Instructions
Collapse adjacent duplicate lines, optionally counting occurrences or showing only unique/duplicate lines. Read-only, no side effects. Returns JSON by default; use --raw for plain output. Use to remove or count consecutive duplicates. IMPORTANT: only works on adjacent duplicates — pipe through 'sort' first for full deduplication. Not for standalone dedup without sorting — always combine with 'sort' for complete duplicate removal. See also 'sort'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | Include duplicate counts in raw output. | |
| encoding | No | Text encoding. | utf-8 |
| ignore_case | No | Compare case-insensitively. | |
| max_lines | No | Maximum JSON groups to emit. | |
| paths | No | Files to read, or '-' for stdin. Defaults to stdin. | |
| raw | No | Write plain transformed text to stdout. | |
| repeated | No | Emit only repeated groups. | |
| unique_only | No | Emit only non-repeated groups. |