Add with_entries example using filtering

This commit is contained in:
Curtis Vogt
2021-06-08 21:38:54 +10:00
committed by Mike Farah
parent fae2b2643c
commit ed377a032d
2 changed files with 24 additions and 0 deletions
+16
View File
@@ -98,3 +98,19 @@ KEY_a: 1
KEY_b: 2
```
Using with_entries is also useful whe you want to filter a map. Given a sample.yml file of:
```yaml
a:
b: bird
c:
d: dog
```
then
```bash
yq eval 'with_entries(select(.value | has("b")))' sample.yml
```
will output
```yaml
a:
b: bird
```