2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: find
|
|
|
|
layout: command
|
2022-03-04 13:10:09 +01:00
|
|
|
version: 0.59.1
|
2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
Searches terms in the input or for elements of the input that satisfies the predicate.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2022-03-01 00:31:53 +01:00
|
|
|
```> find ...rest --predicate --regex --insensitive --multiline --dotall --invert```
|
2022-02-14 03:22:51 +01:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
- `...rest`: terms to search
|
|
|
|
- `--predicate {block}`: the predicate to satisfy
|
2022-03-01 00:31:53 +01:00
|
|
|
- `--regex {string}`: regex to match with
|
|
|
|
- `--insensitive`: case-insensitive search for regex (?i)
|
|
|
|
- `--multiline`: multi-line mode: ^ and $ match begin/end of line for regex (?m)
|
|
|
|
- `--dotall`: dotall mode: allow a dot . to match newline character \n for regex (?s)
|
|
|
|
- `--invert`: invert the match
|
2022-02-14 03:22:51 +01:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
Search for multiple terms in a command output
|
|
|
|
```shell
|
|
|
|
> ls | find toml md sh
|
|
|
|
```
|
|
|
|
|
|
|
|
Search for a term in a string
|
|
|
|
```shell
|
|
|
|
> echo Cargo.toml | find toml
|
|
|
|
```
|
|
|
|
|
|
|
|
Search a number or a file size in a list of numbers
|
|
|
|
```shell
|
|
|
|
> [1 5 3kb 4 3Mb] | find 5 3kb
|
|
|
|
```
|
|
|
|
|
|
|
|
Search a char in a list of string
|
|
|
|
```shell
|
|
|
|
> [moe larry curly] | find l
|
|
|
|
```
|
|
|
|
|
2022-03-01 00:31:53 +01:00
|
|
|
Find odd values
|
2022-02-14 03:22:51 +01:00
|
|
|
```shell
|
2022-03-01 00:31:53 +01:00
|
|
|
> [2 4 3 6 5 8] | find --predicate { |it| ($it mod 2) == 1 }
|
2022-02-14 03:22:51 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Find if a service is not running
|
|
|
|
```shell
|
2022-03-03 01:55:03 +01:00
|
|
|
> [[version patch]; [0.1.0 false] [0.1.1 true] [0.2.0 false]] | find -p { |it| $it.patch }
|
2022-03-01 00:31:53 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Find using regex
|
|
|
|
```shell
|
|
|
|
> [abc bde arc abf] | find --regex "ab"
|
|
|
|
```
|
|
|
|
|
|
|
|
Find using regex case insensitive
|
|
|
|
```shell
|
|
|
|
> [aBc bde Arc abf] | find --regex "ab" -i
|
|
|
|
```
|
|
|
|
|
|
|
|
Find value in records
|
|
|
|
```shell
|
|
|
|
> [[version name]; [0.1.0 nushell] [0.1.1 fish] [0.2.0 zsh]] | find -r "nu"
|
2022-02-14 03:22:51 +01:00
|
|
|
```
|