Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

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:

inputoutput
list<any>list<any>

Examples

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

> [2 3 3 4] | uniq
╭───┬───╮
│ 0 │ 2 │
│ 1 │ 3 │
│ 2 │ 4 │
╰───┴───╯

Return the input values that occur more than once

> [1 2 2] | uniq -d
╭───┬───╮
│ 0 │ 2 │
╰───┴───╯

Return the input values that occur once only

> [1 2 2] | uniq --unique
╭───┬───╮
│ 0 │ 1 │
╰───┴───╯

Ignore differences in case when comparing input values

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

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

> [1 2 2] | uniq --count
╭───┬───────┬───────╮
│ # │ value │ count │
├───┼───────┼───────┤
│ 0 │     1 │     1 │
│ 1 │     2 │     2 │
╰───┴───────┴───────╯