Update multiply docs

This commit is contained in:
Mike Farah 2022-03-16 10:04:13 +11:00
parent 406bbb8ca4
commit d27fb0ec78
2 changed files with 18 additions and 4 deletions

View File

@ -15,9 +15,16 @@ You can control how objects are merged by using one or more of the following fla
- `?` only merge _existing_ fields - `?` only merge _existing_ fields
- `n` only merge _new_ fields - `n` only merge _new_ fields
### Merging files
### Merge two files together
This uses the load operator to merge file2 into file1.
```bash
yq '. *= load("file2.yml")' file1.yml
```
### Merging all files
Note the use of `eval-all` to ensure all documents are loaded into memory. Note the use of `eval-all` to ensure all documents are loaded into memory.
```bash ```bash
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' file1.yaml file2.yaml yq eval-all '. as $item ireduce ({}; . * $item )' *.yml
``` ```

View File

@ -15,11 +15,18 @@ You can control how objects are merged by using one or more of the following fla
- `?` only merge _existing_ fields - `?` only merge _existing_ fields
- `n` only merge _new_ fields - `n` only merge _new_ fields
### Merging files
### Merge two files together
This uses the load operator to merge file2 into file1.
```bash
yq '. *= load("file2.yml")' file1.yml
```
### Merging all files
Note the use of `eval-all` to ensure all documents are loaded into memory. Note the use of `eval-all` to ensure all documents are loaded into memory.
```bash ```bash
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' file1.yaml file2.yaml yq eval-all '. as $item ireduce ({}; . * $item )' *.yml
``` ```
{% hint style="warning" %} {% hint style="warning" %}