Delete

Deletes matching entries in maps or arrays.

Delete entry in map

Given a sample.yml file of:

a: cat
b: dog

then

yq 'del(.b)' sample.yml

will output

a: cat

Delete nested entry in map

Given a sample.yml file of:

a:
  a1: fred
  a2: frood

then

yq 'del(.a.a1)' sample.yml

will output

Delete entry in array

Given a sample.yml file of:

then

will output

Delete nested entry in array

Given a sample.yml file of:

then

will output

Delete no matches

Given a sample.yml file of:

then

will output

Delete matching entries

Given a sample.yml file of:

then

will output

Recursively delete matching keys

Given a sample.yml file of:

then

will output

Last updated

Was this helpful?