Added another |= example

This commit is contained in:
Mike Farah
2021-07-07 19:53:33 +10:00
parent b0074f5eba
commit b4b2e1217a
2 changed files with 28 additions and 2 deletions
+19 -1
View File
@@ -28,6 +28,24 @@ a:
g: foof
```
## Double elements in an array
Given a sample.yml file of:
```yaml
- 1
- 2
- 3
```
then
```bash
yq eval '.[] |= . * 2' sample.yml
```
will output
```yaml
- 2
- 4
- 6
```
## Update node from another file
Note this will also work when the second file is a scalar (string/number)
@@ -75,7 +93,7 @@ c: fieldC
```
then
```bash
yq eval '(.a, .c) |= "potatoe"' sample.yml
yq eval '(.a, .c) = "potatoe"' sample.yml
```
will output
```yaml