-
Hello - yq noob here. Say I have this input: - id: 123
name: "abc"
- id: 456
name: "def" And I want to produce an output array where each line consists of the name as the value and the id as a comment after the value, like so: - abc # 123
- def # 456 How would I achieve this with yq? |
Beta Was this translation helpful? Give feedback.
Answered by
mikefarah
Dec 14, 2023
Replies: 1 comment 1 reply
-
TLDR:
Explanation:
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
alinjie
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TLDR:
Explanation:
.[]
matches every array elementwith(.[] ; ...)
, sets the inner context to each array element, like a for loop. line_comment= .id
sets the line comment of the current element to be the id value. = .name)
sets the current element value to the name value.