find
for filters> find {flags} ...rest
--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...rest
: terms to searchinput | output |
---|---|
list<any> | list<any> |
string | any |
table | table |
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
╭───┬─────────╮
│0│5│
│1│2.9KiB│
╰───┴─────────╯
Search a char in a list of string
> [moelarrycurly] |findl
╭───┬───────╮
│0│larry│
│1│curly│
╰───┴───────╯
Find using regex
> [abcbdearcabf] |find--regex"ab"
╭───┬─────╮
│0│abc│
│1│abf│
╰───┴─────╯
Find using regex case insensitive
> [aBcbdeArcabf] |find--regex"ab"-i
╭───┬─────╮
│0│aBc│
│1│abf│
╰───┴─────╯
Find value in records using regex
> [[versionname]; ['0.1.0'nushell] ['0.1.1'fish] ['0.2.0'zsh]] |find-r"nu"
╭───┬─────────┬─────────╮
│# │ version │ name │
├───┼─────────┼─────────┤
│0│0.1.0│nushell│
╰───┴─────────┴─────────╯
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 │
├───┼─────────┼──────┤
│0│0.1.1│fish│
│1│0.2.0│zsh│
╰───┴─────────┴──────╯
Find value in list using regex
> [["Larry", "Moe"], ["Victor", "Marina"]] |find-r"rr"
╭───┬───────────────╮
│0│╭───┬───────╮│
│││0│Larry││
│││1│Moe││
││╰───┴───────╯│
╰───┴───────────────╯
Find inverted values in records using regex
> [["Larry", "Moe"], ["Victor", "Marina"]] |find-r"rr"--invert
╭───┬────────────────╮
│0│╭───┬────────╮│
│││0│Victor││
│││1│Marina││
││╰───┴────────╯│
╰───┴────────────────╯
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 │
├───┼──────┼───────┼───────┤
│0│moe│larry│curly│
╰───┴──────┴───────┴───────╯
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/find.html