Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To obtain the key and value using yq V4.x.x, you can use the select function.

For example, if you have a YAML file with the following content:

apple: fruit
carrot: vegetable

You can obtain the key and value of the apple key using the following command:

yq eval '.apple | select(dict: .)' file.yaml

This will output:

apple: fruit

The select function takes a dict argument that specifies the key-value pairs to select. In this case, we are selecting the key-value pair where the key equals apple.