1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00
This commit is contained in:
Mike Farah
2020-11-28 10:41:09 +11:00
parent 13679e51e2
commit 3cecb4e383
8 changed files with 135 additions and 53 deletions

View File

@@ -66,9 +66,9 @@ b:
Given a sample.yml file of:
```yaml
a: {things: great}
b:
also: "me"
b:
also: "me"
```
then
```bash
@@ -76,9 +76,6 @@ yq eval '. * {"a":.b}' sample.yml
```
will output
```yaml
a: {things: great, also: "me"}
b:
also: "me"
```
## Merge arrays
@@ -109,6 +106,38 @@ b:
- 5
```
## Merge, appending arrays
Given a sample.yml file of:
```yaml
a:
array:
- 1
- 2
- animal: dog
value: coconut
b:
array:
- 3
- 4
- animal: cat
value: banana
```
then
```bash
yq eval '.a *+ .b' sample.yml
```
will output
```yaml
array:
- 1
- 2
- animal: dog
- 3
- 4
- animal: cat
value: banana
```
## Merge to prefix an element
Given a sample.yml file of:
```yaml