Document multi document read feature

This commit is contained in:
Mike Farah 2018-07-08 21:53:38 +10:00
parent d8fed62f03
commit e55006e935

View File

@ -43,7 +43,7 @@ will output
- apples
```
### Multiple Documents
### Multiple Documents - specify a single document
Given a sample.yaml file of:
```yaml
something: else
@ -57,6 +57,31 @@ yq r -d1 sample.yaml b.c
```
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
You can give an index to access a specific element:
e.g.: given a sample file of