2021-11-03 04:00:58 +00:00
|
|
|
# Union
|
|
|
|
|
|
|
|
This operator is used to combine different results together.
|
|
|
|
|
2022-02-06 03:39:46 +00:00
|
|
|
{% hint style="warning" %}
|
|
|
|
Note that versions prior to 4.18 require the 'eval/e' command to be specified. 
|
|
|
|
|
|
|
|
`yq e <exp> <file>`
|
|
|
|
{% endhint %}
|
|
|
|
|
2021-11-03 04:00:58 +00:00
|
|
|
## Combine scalars
|
|
|
|
Running
|
|
|
|
```bash
|
2022-01-27 06:21:10 +00:00
|
|
|
yq --null-input '1, true, "cat"'
|
2021-11-03 04:00:58 +00:00
|
|
|
```
|
|
|
|
will output
|
|
|
|
```yaml
|
|
|
|
1
|
|
|
|
true
|
|
|
|
cat
|
|
|
|
```
|
|
|
|
|
|
|
|
## Combine selected paths
|
|
|
|
Given a sample.yml file of:
|
|
|
|
```yaml
|
|
|
|
a: fieldA
|
|
|
|
b: fieldB
|
|
|
|
c: fieldC
|
|
|
|
```
|
|
|
|
then
|
|
|
|
```bash
|
2022-01-27 06:21:10 +00:00
|
|
|
yq '.a, .c' sample.yml
|
2021-11-03 04:00:58 +00:00
|
|
|
```
|
|
|
|
will output
|
|
|
|
```yaml
|
|
|
|
fieldA
|
|
|
|
fieldC
|
|
|
|
```
|
|
|
|
|