1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Fixed updating yaml from other files

This commit is contained in:
Mike Farah
2021-01-02 10:27:32 +11:00
parent 4fef4a7ab1
commit 6d512ad718
9 changed files with 108 additions and 23 deletions

View File

@@ -34,6 +34,27 @@ a:
g: foof
```
## Update node from another file
Note this will also work when the second file is a scalar (string/number)
Given a sample.yml file of:
```yaml
a: apples
```
And another sample another.yml file of:
```yaml
b: bob
```
then
```bash
yq eval-all 'select(fileIndex==0).a = select(fileIndex==1) | select(fileIndex==0)' sample.yml another.yml
```
will output
```yaml
a:
b: bob
```
## Update node to be the sibling value
Given a sample.yml file of:
```yaml

View File

@@ -16,7 +16,7 @@ yq eval 'filename' sample.yml
```
will output
```yaml
sample.yaml
sample.yml
```
## Get file index