Skip to content

Split result array into files, but keep all parent keys? #2355

Answered by treatmesubj
treatmesubj asked this question in Q&A

You must be logged in to vote

both of these do what I wanted:

mkdir split &&
    yq '[.spec.templates.[] as $i | ($i | parent(3) | .spec.templates = [$i]) as $f | $f].[] | split_doc' \
    my-pipeline.yaml \
    -s '"./split/" + .spec.templates.[0].templateName'

mkdir split &&
    yq '[.spec.templates.[] as $i | [$i | parent(3) | .spec.templates = [$i]].[0]].[] | split_doc' \
    my-pipeline.yaml \
    -s '"./split/" + .spec.templates.[0].templateName'

Replies: 1 comment

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