mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-03 02:51:40 +00:00
Bumping version
This commit is contained in:
parent
05ee3403ca
commit
c6394d2058
@ -37,7 +37,7 @@ The `=` operator then pipes the 'root' context through the `rhs` expression of `
|
|||||||
dog
|
dog
|
||||||
```
|
```
|
||||||
|
|
||||||
Both sides have now been evaluated, so now the operator copies across the value from the RHS (`.b`) to the the LHS (`.a`), and it returns the now updated context:
|
Both sides have now been evaluated, so now the operator copies across the value from the RHS (`.b`) to the LHS (`.a`), and it returns the now updated context:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
a: dog
|
a: dog
|
||||||
|
|||||||
@ -79,3 +79,36 @@ will output
|
|||||||
cat
|
cat
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Update or create - entity exists
|
||||||
|
This initialises `a` if it's not present
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
a: 1
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq '(.a // (.a = 0)) += 1' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
a: 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update or create - entity does not exist
|
||||||
|
This initialises `a` if it's not present
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
b: camel
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq '(.a // (.a = 0)) += 1' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
b: camel
|
||||||
|
a: 1
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user