Equals

This is a boolean operator that will return true if the LHS is equal to the RHS and false otherwise.

.a == .b

It is most often used with the select operator to find particular nodes:

select(.a == .b)

The not equals != operator returns false if the LHS is equal to the RHS.

  • comparison (>=, < etc) operators here

  • boolean operators (and, or, any etc) here

  • select operator here

Match string

Given a sample.yml file of:

- cat
- goat
- dog

then

yq '.[] | (. == "*at")' sample.yml

will output

Don't match string

Given a sample.yml file of:

then

will output

Match number

Given a sample.yml file of:

then

will output

Don't match number

Given a sample.yml file of:

then

will output

Match nulls

Running

will output

Non existent key doesn't equal a value

Given a sample.yml file of:

then

will output

Two non existent keys are equal

Given a sample.yml file of:

then

will output

Last updated

Was this helpful?