mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-14 15:18:06 +00:00
38 lines
482 B
Markdown
38 lines
482 B
Markdown
# Split into Documents
|
|
|
|
This operator splits all matches into separate documents
|
|
|
|
{% hint style="warning" %}
|
|
Note that versions prior to 4.18 require the 'eval/e' command to be specified. 
|
|
|
|
`yq e <exp> <file>`
|
|
{% endhint %}
|
|
|
|
## Split empty
|
|
Running
|
|
```bash
|
|
yq --null-input 'splitDoc'
|
|
```
|
|
will output
|
|
```yaml
|
|
|
|
```
|
|
|
|
## Split array
|
|
Given a sample.yml file of:
|
|
```yaml
|
|
- a: cat
|
|
- b: dog
|
|
```
|
|
then
|
|
```bash
|
|
yq '.[] | splitDoc' sample.yml
|
|
```
|
|
will output
|
|
```yaml
|
|
a: cat
|
|
---
|
|
b: dog
|
|
```
|
|
|