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
.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-05-10 11:00:00 +0000
Seen: 13 times
Last updated: May 03 '22
Is it impossible to remove brew from MacOS Apple Silicon?
How can the Mac Extended display be restated in different words?
Does the Excel FIND function (case-sensitive) consider case?
How can I add up the value of a different layer's field when it intersects with a polygon in QGIS?
What is the method for de-linearizing the value of the depth buffer?
What is the expected outcome of the math.floor function in terms of the return value?
What is the method to retrieve the value of a checkbox using react-hook-form?