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
Parent
Parent simply returns the parent nodes of the matching nodes.
Note that versions prior to 4.18 require the 'eval/e' command to be specified.
yq e <exp> <file>
Simple example
Given a sample.yml file of:
1
a
:
2
nested
:
cat
Copied!
then
1
yq
'.a.nested | parent'
sample.yml
Copied!
will output
1
nested
:
cat
Copied!
Parent of nested matches
Given a sample.yml file of:
1
a
:
2
fruit
:
apple
3
name
:
bob
4
b
:
5
fruit
:
banana
6
name
:
sam
Copied!
then
1
yq
'.. | select(. == "banana") | parent'
sample.yml
Copied!
will output
1
fruit
:
banana
2
name
:
sam
Copied!
No parent
Given a sample.yml file of:
1
{}
Copied!
then
1
yq
'parent'
sample.yml
Copied!
will output
1
Copied!
Previous
Multiply (Merge)
Next
Path
Last modified
4mo ago
Copy link
Contents
Simple example
Parent of nested matches
No parent