mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
Updated docs to explicity put array paths in quotes
This commit is contained in:
@@ -68,10 +68,12 @@ b:
|
||||
```
|
||||
then
|
||||
```
|
||||
yq r sample.yaml b.e[1].name
|
||||
yq r sample.yaml 'b.e[1].name'
|
||||
```
|
||||
will output 'sam'
|
||||
|
||||
Note that the path is in quotes to avoid the square brackets being interpreted by your shell.
|
||||
|
||||
### Array Splat
|
||||
e.g.: given a sample file of
|
||||
```yaml
|
||||
@@ -84,12 +86,13 @@ b:
|
||||
```
|
||||
then
|
||||
```
|
||||
yq r sample.yaml b.e[*].name
|
||||
yq r sample.yaml 'b.e[*].name'
|
||||
```
|
||||
will output:
|
||||
```
|
||||
- fred
|
||||
- sam
|
||||
```
|
||||
Note that the path is in quotes to avoid the square brackets being interpreted by your shell.
|
||||
|
||||
{!snippets/keys_with_dots.md!}
|
||||
|
||||
@@ -7,11 +7,13 @@ b:
|
||||
```
|
||||
|
||||
```bash
|
||||
yaml r sample.yaml b[foo.bar]
|
||||
yaml r sample.yaml 'b[foo.bar]'
|
||||
```
|
||||
|
||||
```bash
|
||||
yaml w sample.yaml b[foo.bar] 9
|
||||
yaml w sample.yaml 'b[foo.bar]' 9
|
||||
```
|
||||
|
||||
Any valid yaml key can be specified as part of a key lookup.
|
||||
|
||||
Note that the path is in quotes to avoid the square brackets being interpreted by your shell.
|
||||
|
||||
@@ -55,7 +55,7 @@ b:
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq w sample.yaml b.d[+] "bar thing"
|
||||
yq w sample.yaml "b.d[+]" "bar thing"
|
||||
```
|
||||
will output:
|
||||
```yaml
|
||||
@@ -67,6 +67,8 @@ b:
|
||||
- bar thing
|
||||
```
|
||||
|
||||
Note that the path is in quotes to avoid the square brackets being interpreted by your shell.
|
||||
|
||||
### Updating files in-place
|
||||
Given a sample.yaml file of:
|
||||
```yaml
|
||||
|
||||
Reference in New Issue
Block a user