yq/operators/split-into-documents.md

32 lines
336 B
Markdown
Raw Normal View History

2021-10-30 03:14:39 +00:00
# Split into Documents
This operator splits all matches into separate documents
## Split empty
Running
```bash
2022-02-15 03:16:04 +00:00
yq --null-input 'split_doc'
2021-10-30 03:14:39 +00:00
```
will output
```yaml
2021-11-03 04:00:28 +00:00
2021-10-30 03:14:39 +00:00
```
## Split array
Given a sample.yml file of:
```yaml
- a: cat
- b: dog
```
then
```bash
2022-02-15 03:16:04 +00:00
yq '.[] | split_doc' sample.yml
2021-10-30 03:14:39 +00:00
```
will output
```yaml
a: cat
---
b: dog
```
2021-11-03 04:00:28 +00:00