uniq

Table of Contents

Operator

uniq — deduplicate adjacent values

Synopsis

uniq [-c]

Description

Inspired by the traditional Unix shell command of the same name, the uniq operator copies its input to its output but removes duplicate values that are adjacent to one another.

This operator is most often used with cut and sort to find and eliminate duplicate values.

When run with the -c option, each value is output as a record with the type signature {value:any,count:uint64}, where the value field contains the unique value and the count field indicates the number of consecutive duplicates that occurred in the input for that output value.

Examples

Simple deduplication

Error:
echo '1 2 2 3' | super -z -c uniq -

Simple deduplication with -c

uniq -c
1
2
2
3
Loading...

Use sort to deduplicate non-adjacent values

sort |> uniq
"hello"
"world"
"goodbye"
"world"
"hello"
"again"
Loading...

Complex values must match fully to be considered duplicate (e.g., every field/value pair in adjacent records)

uniq
{ts:2024-09-10T21:12:33Z,
action:"start"}






{ts:2024-09-10T21:12:34Z,
action:"running"}






{ts:2024-09-10T21:12:34Z,
action:"running"}






{ts:2024-09-10T21:12:35Z,
action:"running"}






{ts:2024-09-10T21:12:36Z,
action:"stop"}
Loading...
Next: where

SuperDB