yq/pkg/yqlib/doc/operators/omit.md
2024-03-23 17:15:45 +11:00

634 B

Omit keys from map

Note that the order of the keys matches the omit order and non existent keys are skipped.

Given a sample.yml file of:

myMap:
  cat: meow
  dog: bark
  thing: hamster
  hamster: squeak

then

yq '.myMap |= omit(["hamster", "cat", "goat"])' sample.yml

will output

myMap:
  dog: bark
  thing: hamster

Omit indices from array

Note that the order of the indices matches the omit order and non existent indices are skipped.

Given a sample.yml file of:

- cat
- leopard
- lion

then

yq 'omit([2, 0, 734, -5])' sample.yml

will output

- leopard