y
y
yq
Search…
y
y
yq
v4.x
yq
How It Works
Upgrading from V3
Commands
Evaluate
Evaluate All
Shell Completion
Operators
Add
Alternative (Default value)
Anchor and Alias Operators
Assign (Update)
Boolean Operators
Collect into Array
Column
Comment Operators
Compare Operators
Contains
Create, Collect into Object
Date Time
Delete
Document Index
Encode / Decode
Entries
Env Variable Operators
Equals
Eval
File Operators
Flatten
Group By
Has
Keys
Length
Line
Load
Map
Multiply (Merge)
Parent
Path
Pick
Pipe
Recursive Descent (Glob)
Reduce
Reverse
Select
Sort
Sort Keys
Split into Documents
String Operators
Style
Subtract
Tag
Traverse (Read)
Union
Unique
Variable Operators
With
Usage
Output format
Working with CSV, TSV
Working with JSON
Working with Properties
Working with XML
Front Matter
Split into multiple files
GitHub Action
Tips, Tricks, Troubleshooting
Github Page
Powered By
GitBook
Equals
This is a boolean operator that will return
true
if the LHS is equal to the RHS and
false
otherwise.
1
.a == .b
Copied!
It is most often used with the select operator to find particular nodes:
1
select(.a == .b)
Copied!
The not equals
!=
operator returns
false
if the LHS is equal to the RHS.
Related Operators
comparison (
>=
,
<
etc) operators
here
​
boolean operators (
and
,
or
,
any
etc)
here
​
select operator
here
​
Note that versions prior to 4.18 require the 'eval/e' command to be specified.
yq e <exp> <file>
Match string
Given a sample.yml file of:
1
-
cat
2
-
goat
3
-
dog
Copied!
then
1
yq
'.[] | (. == "*at")'
sample.yml
Copied!
will output
1
true
2
true
3
false
Copied!
Don't match string
Given a sample.yml file of:
1
-
cat
2
-
goat
3
-
dog
Copied!
then
1
yq
'.[] | (. != "*at")'
sample.yml
Copied!
will output
1
false
2
false
3
true
Copied!
Match number
Given a sample.yml file of:
1
-
3
2
-
4
3
-
5
Copied!
then
1
yq
'.[] | (. == 4)'
sample.yml
Copied!
will output
1
false
2
true
3
false
Copied!
Don't match number
Given a sample.yml file of:
1
-
3
2
-
4
3
-
5
Copied!
then
1
yq
'.[] | (. != 4)'
sample.yml
Copied!
will output
1
true
2
false
3
true
Copied!
Match nulls
Running
1
yq --null-input
'null == ~'
Copied!
will output
1
true
Copied!
Non existent key doesn't equal a value
Given a sample.yml file of:
1
a
:
frog
Copied!
then
1
yq
'select(.b != "thing")'
sample.yml
Copied!
will output
1
a
:
frog
Copied!
Two non existent keys are equal
Given a sample.yml file of:
1
a
:
frog
Copied!
then
1
yq
'select(.b == .c)'
sample.yml
Copied!
will output
1
a
:
frog
Copied!
Previous
Env Variable Operators
Next
Eval
Last modified
1mo ago
Copy link
Contents
Related Operators
Match string
Don't match string
Match number
Don't match number
Match nulls
Non existent key doesn't equal a value
Two non existent keys are equal