mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
657 B
657 B
The or
and and
operators take two parameters and return a boolean result. These are most commonly used with the select
operator to filter particular nodes.
Examples
OR example
Running
yq eval --null-input 'true or false'
will output
true
AND example
Running
yq eval --null-input 'true and false'
will output
false
Matching nodes with select, equals and or
Given a sample.yml file of:
- a: bird
b: dog
- a: frog
b: bird
- a: cat
b: fly
then
yq eval '.[] | select(.a == "cat" or .b == "dog")' sample.yml
will output
a: bird
b: dog
a: cat
b: fly