mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-05 17:36:59 +08:00
Update document generation script
This commit is contained in:
+2
-13
@@ -1,47 +1,36 @@
|
||||
# Keys
|
||||
|
||||
Use the `keys` operator to return map keys or array indices.
|
||||
Use the `keys` operator to return map keys or array indices.
|
||||
|
||||
## Map keys
|
||||
|
||||
Given a sample.yml file of:
|
||||
|
||||
```yaml
|
||||
dog: woof
|
||||
cat: meow
|
||||
```
|
||||
|
||||
then
|
||||
|
||||
```bash
|
||||
yq eval 'keys' sample.yml
|
||||
```
|
||||
|
||||
will output
|
||||
|
||||
```yaml
|
||||
- dog
|
||||
- cat
|
||||
```
|
||||
|
||||
## Array keys
|
||||
|
||||
Given a sample.yml file of:
|
||||
|
||||
```yaml
|
||||
- apple
|
||||
- banana
|
||||
```
|
||||
|
||||
then
|
||||
|
||||
```bash
|
||||
yq eval 'keys' sample.yml
|
||||
```
|
||||
|
||||
will output
|
||||
|
||||
```yaml
|
||||
- 0
|
||||
- 1
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user