yq/pkg/yqlib/doc/parent.md
2021-11-24 10:16:48 +11:00

501 B

Simple example

Given a sample.yml file of:

a:
  nested: cat

then

yq eval '.a.nested | parent' sample.yml

will output

nested: cat

Show parent

Given a sample.yml file of:

a:
  fruit: apple
b:
  fruit: banana

then

yq eval '.. | select(. == "banana") | parent' sample.yml

will output

fruit: banana

No parent

Given a sample.yml file of:

{}

then

yq eval 'parent' sample.yml

will output