WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Discussion options

You must be logged in to vote

Probably way to late for you now (sorry); but for future readers:

You'll need to use the -s command to split each result into their own file.

So the first step is to work out how to split up the doc into the components that you want in each file, then the next step is to work out the right expression to give to '-s' to generate the filenames.

First Option (easier)

yq -s '(parent | key) + "_" + (key) ' '.regions[][]' examples/data1.yaml
  • The main expression splits over each "item" value map
    e.g. for the path .regions.region2.item1:
settingA: something
settingB: configured

Then the -s expression is run against that match to generate the filename. We can use 'parent' to go up the node tre…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dmc-94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants