mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
Document multi document read feature
This commit is contained in:
parent
d8fed62f03
commit
e55006e935
@ -43,7 +43,7 @@ will output
|
|||||||
- apples
|
- apples
|
||||||
```
|
```
|
||||||
|
|
||||||
### Multiple Documents
|
### Multiple Documents - specify a single document
|
||||||
Given a sample.yaml file of:
|
Given a sample.yaml file of:
|
||||||
```yaml
|
```yaml
|
||||||
something: else
|
something: else
|
||||||
@ -57,6 +57,31 @@ yq r -d1 sample.yaml b.c
|
|||||||
```
|
```
|
||||||
will output the value of '2'.
|
will output the value of '2'.
|
||||||
|
|
||||||
|
### Multiple Documents - read all documents
|
||||||
|
Reading all documents will return the result as an array. This can be converted to json using the '-j' flag if desired.
|
||||||
|
|
||||||
|
Given a sample.yaml file of:
|
||||||
|
```yaml
|
||||||
|
name: Fred
|
||||||
|
age: 22
|
||||||
|
---
|
||||||
|
name: Stella
|
||||||
|
age: 23
|
||||||
|
---
|
||||||
|
name: Android
|
||||||
|
age: 232
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq r -d'*' sample.yaml name
|
||||||
|
```
|
||||||
|
will output:
|
||||||
|
```
|
||||||
|
- Fred
|
||||||
|
- Stella
|
||||||
|
- Android
|
||||||
|
```
|
||||||
|
|
||||||
### Arrays
|
### Arrays
|
||||||
You can give an index to access a specific element:
|
You can give an index to access a specific element:
|
||||||
e.g.: given a sample file of
|
e.g.: given a sample file of
|
||||||
|
Loading…
Reference in New Issue
Block a user