mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-05 00:54:51 +08:00
Add with_entries example using filtering
This commit is contained in:
@@ -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
|
||||
```
|
||||
Reference in New Issue
Block a user