Parent
Parent simply returns the parent nodes of the matching nodes.
Given a sample.yml file of:
a:
nested: cat
then
yq '.a.nested | parent' sample.yml
will output
nested: cat
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
Given a sample.yml file of:
{}
then
yq 'parent' sample.yml
will output
Last modified 10mo ago