y
y
yq
Search…
y
y
yq
v4.x
yq
How It Works
Upgrading from V3
Commands
Evaluate
Evaluate All
Shell Completion
Operators
Add
Alternative (Default value)
Anchor and Alias Operators
Assign (Update)
Boolean Operators
Collect into Array
Column
Comment Operators
Compare Operators
Contains
Create, Collect into Object
Date Time
Delete
Document Index
Encode / Decode
Entries
Env Variable Operators
Equals
Eval
File Operators
Flatten
Group By
Has
Keys
Length
Line
Load
Map
Multiply (Merge)
Parent
Path
Pick
Pipe
Recursive Descent (Glob)
Reduce
Reverse
Select
Sort
Sort Keys
Split into Documents
String Operators
Style
Subtract
Tag
Traverse (Read)
Union
Unique
Variable Operators
With
Usage
Output format
Working with CSV, TSV
Working with JSON
Working with Properties
Working with XML
Front Matter
Split into multiple files
GitHub Action
Tips, Tricks, Troubleshooting
Github Page
Powered By
GitBook
Delete
Deletes matching entries in maps or arrays.
Note that versions prior to 4.18 require the 'eval/e' command to be specified.
yq e <exp> <file>
Delete entry in map
Given a sample.yml file of:
1
a
:
cat
2
b
:
dog
Copied!
then
1
yq
'del(.b)'
sample.yml
Copied!
will output
1
a
:
cat
Copied!
Delete nested entry in map
Given a sample.yml file of:
1
a
:
2
a1
:
fred
3
a2
:
frood
Copied!
then
1
yq
'del(.a.a1)'
sample.yml
Copied!
will output
1
a
:
2
a2
:
frood
Copied!
Delete entry in array
Given a sample.yml file of:
1
-
1
2
-
2
3
-
3
Copied!
then
1
yq
'del(.[1])'
sample.yml
Copied!
will output
1
-
1
2
-
3
Copied!
Delete nested entry in array
Given a sample.yml file of:
1
-
a
:
cat
2
b
:
dog
Copied!
then
1
yq
'del(.[0].a)'
sample.yml
Copied!
will output
1
-
b
:
dog
Copied!
Delete no matches
Given a sample.yml file of:
1
a
:
cat
2
b
:
dog
Copied!
then
1
yq
'del(.c)'
sample.yml
Copied!
will output
1
a
:
cat
2
b
:
dog
Copied!
Delete matching entries
Given a sample.yml file of:
1
a
:
cat
2
b
:
dog
3
c
:
bat
Copied!
then
1
yq
'del( .[] | select(. == "*at") )'
sample.yml
Copied!
will output
1
b
:
dog
Copied!
Recursively delete matching keys
Given a sample.yml file of:
1
a
:
2
name
:
frog
3
b
:
4
name
:
blog
5
age
:
12
Copied!
then
1
yq
'del(.. | select(has("name")).name)'
sample.yml
Copied!
will output
1
a
:
2
b
:
3
age
:
12
Copied!
Previous
Date Time
Next
Document Index
Last modified
4mo ago
Copy link
Contents
Delete entry in map
Delete nested entry in map
Delete entry in array
Delete nested entry in array
Delete no matches
Delete matching entries
Recursively delete matching keys