How to extract data with parent key's name included in output #1414
Unanswered
jimbuitt-trovata
asked this question in
Q&A
Replies: 1 comment
-
Good question - I've just updated the docs with an example:https://mikefarah.gitbook.io/yq/operators/path#set-path-to-prune-deep-paths) (fixed link) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm attempting to strip out sections of a YAML file to generate a new YAML file from a subset of its keys. To do that, I need to extract keys and their values while keeping the desired key in the output.
For example, if I have
test.yaml
like the following:To extract
rootkey2
, normally I would run:yq .rootkey2 test.yaml
which gives:
However, I would like to get the output:
Is there a query that gets me both the key name and its value?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions