Now you can also use variants of pick
(or omit
) given a sample.yml file of:
myMap:
cat: meow
dog: bark
thing: hamster
hamster: squeak
then
yq '.myMap |= pick(["hamster", "cat", "goat"])' sample.yml
will output
myMap:
hamster: squeak
cat: meow
See https://mikefarah.gitbook.io/yq/operators/pick#pick-keys-from-map