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

Parent

Parent simply returns the parent nodes of the matching nodes.

Simple example

Given a sample.yml file of:
a:
nested: cat
then
yq '.a.nested | parent' sample.yml
will output
nested: cat

Parent of nested matches

Given a sample.yml file of:
a:
fruit: apple
name: bob
b:
fruit: banana
name: sam
then
yq '.. | select(. == "banana") | parent' sample.yml
will output
fruit: banana
name: sam

No parent

Given a sample.yml file of:
{}
then
yq 'parent' sample.yml
will output
​
Previous
Multiply (Merge)
Next
Path
Last modified 4mo ago
Copy link
On this page
Simple example
Parent of nested matches
No parent