Keys
Use the keys operator to return map keys or array indices.
Map keys
Given a sample.yml file of:
dog: woof
cat: meowthen
yq 'keys' sample.ymlwill output
- dog
- catArray keys
Given a sample.yml file of:
- apple
- bananathen
yq 'keys' sample.ymlwill output
Retrieve array key
Given a sample.yml file of:
then
will output
Retrieve map key
Given a sample.yml file of:
then
will output
No key
Given a sample.yml file of:
then
will output
Update map key
Given a sample.yml file of:
then
will output
Get comment from map key
Given a sample.yml file of:
then
will output
Check node is a key
Given a sample.yml file of:
then
will output
Last updated
Was this helpful?