split into multiple multidocs files #1799
Replies: 2 comments
-
I can't think of a way to do it in a single
This will read all the documents from the stream, group it by '.test' and then write out the documents to separate files. Each file is an array of results though, not separate yaml documents. For instance, b.yml: ---
- name: second
test: b
- name: third
test: b Now you need to iterate over all those files (e.g. bash/find) and run this yq command to update each file from an array to a bunch of documents:
b.yml now looks like: name: second
test: b
---
name: third
test: b For example, you can do this using find:
|
Beta Was this translation helpful? Give feedback.
-
Hi, thank you for your help. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am trying to split documents coming from stdin into multiple files based on a specific field.
Something like
and I do get one file for each
test
field value. Unfortunately, I have multiple documents with the same value and I would like them to endup into the same file.for example this:
Should result in two files:
a.yml
b.yml
I have spent quite some time on this and I didn't really fine anything that could help. Could somebody give me a hint?
Beta Was this translation helpful? Give feedback.
All reactions