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

intersect for filters

Returns a list of unique elements present in both the input and the provided list.

Signature

> intersect {flags} (other)

Parameters

  • other: The other list to intersect with.

Input/output types:

inputoutput
list<any>list<any>
tabletable

Examples

Return the intersection of two lists

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

Intersection with no common elements

> [1 2 3] | intersect [4 5 6]
╭────────────╮
│ empty list │
╰────────────╯

Intersection of two tables

> [{a:1} {a:2} {a:3}] | intersect [{a:2} {a:3} {a:4}]
╭───┬───╮
│ # │ a │
├───┼───┤
│ 0 │ 2 │
│ 1 │ 3 │
╰───┴───╯