y
y
yq
v4.x
Search
⌃K
v4.x
y
y
yq
v4.x
Search
⌃K
yq
How It Works
Upgrading from V3
Commands
Evaluate
Evaluate All
Shell Completion
Operators
Add
Alternative (Default value)
Anchor and Alias Operators
Array to Map
Assign (Update)
Boolean Operators
Collect into Array
Column
Comment Operators
Compare Operators
Contains
Create, Collect into Object
Date Time
Delete
Divide
Document Index
Encode / Decode
Entries
Env Variable Operators
Equals
Eval
File Operators
Filter Operator
Flatten
Group By
Has
Keys
Length
Line
Load
Map
Modulo
Multiply (Merge)
Parent
Path
Pick
Pipe
Recursive Descent (Glob)
Reduce
Reverse
Select
Shuffle
Slice Array
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
Working with TOML
Front Matter
Split into multiple files
GitHub Action
Tips, Tricks, Troubleshooting
Github Page
Powered By GitBook

Filter Operator

Filters an array (or map values) by the expression given. Equivalent to doing map(select(exp)).

Filter array

Given a sample.yml file of:
- 1
- 2
- 3
then
yq 'filter(. < 3)' sample.yml
will output
- 1
- 2

Filter map values

Given a sample.yml file of:
c:
things: cool
frog: yes
d:
things: hot
frog: false
then
yq 'filter(.things == "cool")' sample.yml
will output
- things: cool
frog: yes
Previous
File Operators
Next
Flatten
Last modified 14d ago
Copy link
On this page
Filter array
Filter map values