How to perform an replace-only update of a multidoc file #816
-
For example, if I have a file: a:
b: 1
---
a:
c: 2
---
a:
b: 5 and want to update all existing instances of a:
b: 10
---
a:
c: 2
b: 10
---
a:
b: 10 which adds a new b: 10
---
b: 10 yq3 has a workaround in the merge command that lets me get the output I would like (even if it's a bit clunky to use): a:
b: 10
---
a:
c: 2
---
a:
b: 10 is there an equivalent yq4 eval that gets the same output? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You just need to filter out the nodes that don't have
|
Beta Was this translation helpful? Give feedback.
-
@mikefarah how to replace all key, values? provided command updates the matching value, what i want is to replace a.b and a.c with provided input:
expected output
|
Beta Was this translation helpful? Give feedback.
You just need to filter out the nodes that don't have
.a.b
on the LHS of the update operator: