Search

Description

Search selectors recursively search all the data below the current node and return all of the results.

Usage

This must be used in conjunction with the -m, --multiple flag.
1
.(?:<key>=<value>)
Copied!

Key

The key defines which property/selector we should use to extract a value.
If <key> is:
  • . or value - dasel checks if the current nodes value is <value>.
  • - or keyValue - dasel checks if the key/name/index of the current node is <value>.
  • Else dasel uses the key as a selector itself and compares the result against <value>.

Value

The value is the expected value for the check to pass.
Note that dasel will stringy values prior to checking if they match.

Comparisons

Dasel supports the following comparison operators:
Operator
Supported since
=
v1.6.0
!=
v1.17.0

Example

input.json
1
{
2
"users": [
3
{
4
"primary": true,
5
"name": {
6
"first": "Tom",
7
"last": "Wright"
8
}
9
},
10
{
11
"primary": false,
12
"extra": {
13
"name": {
14
"first": "Joe",
15
"last": "Blogs"
16
}
17
},
18
"name": {
19
"first": "Jim",
20
"last": "Wright"
21
}
22
}
23
]
24
}
Copied!

Search by key name

1
dasel select -f input.json -m '.(?:-=name).first'
2
​
3
"Tom"
4
"Joe"
5
"Jim"
Copied!

Search by selector

1
dasel select -f input.json -m '.(?:.name.last=Wright).name.first'
2
​
3
"Tom"
4
"Jim"
Copied!
Last modified 3mo ago