Omit
Works like pick, but instead you specify the keys/indices that you don't want included.
Omit keys from map
Note that non existent keys are skipped.
Given a sample.yml file of:
myMap:
cat: meow
dog: bark
thing: hamster
hamster: squeakthen
yq '.myMap |= omit(["hamster", "cat", "goat"])' sample.ymlwill output
myMap:
dog: bark
thing: hamsterOmit indices from array
Note that non existent indices are skipped.
Given a sample.yml file of:
- cat
- leopard
- lionthen
yq 'omit([2, 0, 734, -5])' sample.ymlwill output
- leopardLast updated
Was this helpful?