W3cubDocs

/Nushell

find for filters

Searches terms in the input.

Signature

> find {flags} ...rest

Flags

  • --regex, -r {string}: regex to match with
  • --ignore-case, -i: case-insensitive regex mode; equivalent to (?i)
  • --multiline, -m: multi-line regex mode: ^ and $ match begin/end of line; equivalent to (?m)
  • --dotall, -s: dotall regex mode: allow a dot . to match newlines \n; equivalent to (?s)
  • --columns, -c {list<string>}: column names to be searched (with rest parameter, not regex yet)
  • --invert, -v: invert the match

Parameters

  • ...rest: terms to search

Input/output types:

input output
list<any> list<any>
string any
table table

Examples

Search for multiple terms in a command output

>ls|findtomlmdsh

Search for a term in a string

>'Cargo.toml'|findtoml
Cargo.toml

Search a number or a file size in a list of numbers

> [153kb43Mb] |find53kb
╭───┬─────────╮
05
12.9KiB
╰───┴─────────╯

Search a char in a list of string

> [moelarrycurly] |findl
╭───┬───────╮
0larry
1curly
╰───┴───────╯

Find using regex

> [abcbdearcabf] |find--regex"ab"
╭───┬─────╮
0abc
1abf
╰───┴─────╯

Find using regex case insensitive

> [aBcbdeArcabf] |find--regex"ab"-i
╭───┬─────╮
0aBc
1abf
╰───┴─────╯

Find value in records using regex

> [[versionname]; ['0.1.0'nushell] ['0.1.1'fish] ['0.2.0'zsh]] |find-r"nu"
╭───┬─────────┬─────────╮
# │ version │  name   │
├───┼─────────┼─────────┤
00.1.0nushell
╰───┴─────────┴─────────╯

Find inverted values in records using regex

> [[versionname]; ['0.1.0'nushell] ['0.1.1'fish] ['0.2.0'zsh]] |find-r"nu"--invert
╭───┬─────────┬──────╮
# │ version │ name │
├───┼─────────┼──────┤
00.1.1fish
10.2.0zsh
╰───┴─────────┴──────╯

Find value in list using regex

> [["Larry", "Moe"], ["Victor", "Marina"]] |find-r"rr"
╭───┬───────────────╮
0╭───┬───────╮
0Larry
1Moe
╰───┴───────╯
╰───┴───────────────╯

Find inverted values in records using regex

> [["Larry", "Moe"], ["Victor", "Marina"]] |find-r"rr"--invert
╭───┬────────────────╮
0╭───┬────────╮
0Victor
1Marina
╰───┴────────╯
╰───┴────────────────╯

Remove ANSI sequences from result

> [[foobar]; [abc123] [def456]] |find123|getbar|ansi strip

Find and highlight text in specific columns

> [[col1col2col3]; [moelarrycurly] [larrycurlymoe]] |findmoe-c [col1]
╭───┬──────┬───────┬───────╮
# │ col1 │ col2  │ col3  │
├───┼──────┼───────┼───────┤
0moelarrycurly
╰───┴──────┴───────┴───────╯

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