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
Contains
This returns
true
if the context contains the passed in parameter, and false otherwise.
Note that versions prior to 4.18 require the 'eval/e' command to be specified.
yq e <exp> <file>
Array contains array
Array is equal or subset of
Given a sample.yml file of:
1
-
foobar
2
-
foobaz
3
-
blarp
Copied!
then
1
yq
'contains(["baz", "bar"])'
sample.yml
Copied!
will output
1
true
Copied!
Object included in array
Given a sample.yml file of:
1
"foo"
:
12
2
"bar"
:
3
-
1
4
-
2
5
-
"barp"
:
12
6
"blip"
:
13
Copied!
then
1
yq
'contains({"bar": [{"barp": 12}]})'
sample.yml
Copied!
will output
1
true
Copied!
Object not included in array
Given a sample.yml file of:
1
"foo"
:
12
2
"bar"
:
3
-
1
4
-
2
5
-
"barp"
:
12
6
"blip"
:
13
Copied!
then
1
yq
'contains({"foo": 12, "bar": [{"barp": 15}]})'
sample.yml
Copied!
will output
1
false
Copied!
String contains substring
Given a sample.yml file of:
1
foobar
Copied!
then
1
yq
'contains("bar")'
sample.yml
Copied!
will output
1
true
Copied!
String equals string
Given a sample.yml file of:
1
meow
Copied!
then
1
yq
'contains("meow")'
sample.yml
Copied!
will output
1
true
Copied!
Previous
Compare Operators
Next
Create, Collect into Object
Last modified
4mo ago
Copy link
Contents
Array contains array
Object included in array
Object not included in array
String contains substring
String equals string