W3cubDocs

/Nushell

uniq for filters

Return the distinct values in the input.

Signature

> uniq {flags}

Flags

  • --count, -c: Return a table containing the distinct input values together with their counts
  • --repeated, -d: Return the input values that occur more than once
  • --ignore-case, -i: Compare input values case-insensitively
  • --unique, -u: Return the input values that occur once only

Input/output types:

input output
list<any> list<any>

Examples

Return the distinct values of a list/table (remove duplicates so that each value occurs once only)

> [2334] |uniq
╭───┬───╮
02
13
24
╰───┴───╯

Return the input values that occur more than once

> [122] |uniq-d
╭───┬───╮
02
╰───┴───╯

Return the input values that occur once only

> [122] |uniq-u
╭───┬───╮
01
╰───┴───╯

Ignore differences in case when comparing input values

> ['hello''goodbye''Hello'] |uniq-i
╭───┬─────────╮
0hello
1goodbye
╰───┴─────────╯

Return a table containing the distinct input values together with their counts

> [122] |uniq-c
╭───┬───────┬───────╮
# │ value │ count │
├───┼───────┼───────┤
011
122
╰───┴───────┴───────╯

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/uniq.html