I have a big yaml file:
---
foo: bar
baz:
bacon: true
eggs: false
---
goo: car
star:
cheese: true
water: false
---
dog: boxer
food:
turkey: true
moo: cow
---
...
What i'd like to do is split this file into n-number of valid yaml files.
I attempted doing this with csplit in bash:
But ultimately end up with either a lot more files than I want:
csplit --elide-empty-files -f rendered- example.yaml "/---/" "{*}"
or a split where the last file contains most of the content:
csplit --elide-empty-files -n 3 -f rendered- app.yaml "/---/" "{3}"
This is non-ideal. What I really want is the ability to say, split a yaml file in thirds where it splits on the closest delimiter. I know that won't always be truly thirds.
Any ideas on how to accomplish this in bash?