The or
and and
operators take two parameters and return a boolean result. not
flips a boolean from true to false, or vice versa. These are most commonly used with the select
operator to filter particular nodes.
Running
yq eval --null-input 'true or false'
will output
true
Running
yq eval --null-input 'true and false'
will output
false
Given a sample.yml file of:
- a: birdb: dog- a: frogb: bird- a: catb: fly
then
yq eval '[.[] | select(.a == "cat" or .b == "dog")]' sample.yml
will output
- a: birdb: dog- a: catb: fly
Running
yq eval --null-input 'true | not'
will output
false
Running
yq eval --null-input 'false | not'
will output
true
Running
yq eval --null-input '"cat" | not'
will output
false
Running
yq eval --null-input '"" | not'
will output
false
Running
yq eval --null-input '1 | not'
will output
false
Running
yq eval --null-input '0 | not'
will output
false
Running
yq eval --null-input '~ | not'
will output
true