each
The each function iterates through each item of an array, similar to a foreach loop.
The current item is accessible via the $this variable. The current index is accessible via $key.
The return values from each are ignored — it is useful when you want to modify values in-place.
Most commonly used with:
--rootflag
Syntax
<array>.each(expression)Examples
Modifying data in-place
$ echo '[1, 2, 3]' | dasel -i json 'each($this = $this + 1)'
[
2,
3,
4
]Uppercase all names in a file
Combined with search — update deeply nested values
This finds all objects with a status field anywhere in the document and sets them to "active".
Last updated