Added prepend array example

This commit is contained in:
Mike Farah
2023-01-11 12:19:46 +11:00
parent 9af55d555b
commit 00c2be541d
2 changed files with 25 additions and 0 deletions
+17
View File
@@ -86,6 +86,23 @@ will output
a: ['dog', 'cat']
```
## Prepend to existing array
Given a sample.yml file of:
```yaml
a:
- dog
```
then
```bash
yq '.a = ["cat"] + .a' sample.yml
```
will output
```yaml
a:
- cat
- dog
```
## Add new object to array
Given a sample.yml file of:
```yaml