1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Added recurse examples

This commit is contained in:
Mike Farah
2021-01-08 12:11:29 +11:00
parent db62a16007
commit ceff2cc18d
2 changed files with 60 additions and 0 deletions

View File

@@ -32,6 +32,48 @@ a: frog
frog
```
## Recursively find nodes with keys
Given a sample.yml file of:
```yaml
a:
name: frog
b:
name: blog
age: 12
```
then
```bash
yq eval '.. | select(has("name"))' sample.yml
```
will output
```yaml
name: frog
b:
name: blog
age: 12
name: blog
age: 12
```
## Recursively find nodes with values
Given a sample.yml file of:
```yaml
a:
nameA: frog
b:
nameB: frog
age: 12
```
then
```bash
yq eval '.. | select(. == "frog")' sample.yml
```
will output
```yaml
frog
frog
```
## Recurse map (values and keys)
Note that the map key appears in the results