This operator recursively matches (or globs) all children nodes given of a particular element, including that node itself. This is most often used to apply a filter recursively against all matches. It can be used in either the
This will, like the jq
equivalent, recursively match all value nodes. Use it to find/manipulate particular values.
For instance to set the style
of all value nodes in a yaml doc, excluding map keys:
yq eval '.. style= "flow"' file.yaml
The also includes map keys in the results set. This is particularly useful in YAML as unlike JSON, map keys can have their own styling, tags and use anchors and aliases.
For instance to set the style
of all nodes in a yaml doc, including the map keys:
yq eval '... style= "flow"' file.yaml
Given a sample.yml file of:
a: frog
then
yq eval '..' sample.yml
will output
a: frogfrog
Note that this example has wrapped the expression in []
to show that there are two matches returned. You do not have to wrap in []
in your path expression.
Given a sample.yml file of:
a:name: frogb:name: blogage: 12
then
yq eval '[.. | select(has("name"))]' sample.yml
will output
- name: frogb:name: blogage: 12- name: blogage: 12
Given a sample.yml file of:
a:nameA: frogb:nameB: frogage: 12
then
yq eval '.. | select(. == "frog")' sample.yml
will output
frogfrog
Note that the map key appears in the results
Given a sample.yml file of:
a: frog
then
yq eval '...' sample.yml
will output
a: frogafrog
Given a sample.yml file of:
a: &catc: frogb: *cat
then
yq eval '[..]' sample.yml
will output
- a: &catc: frogb: *cat- &catc: frog- frog- *cat
Given a sample.yml file of:
foo: &fooa: foo_athing: foo_thingc: foo_cbar: &barb: bar_bthing: bar_thingc: bar_cfoobarList:b: foobarList_b!!merge <<:- *foo- *barc: foobarList_cfoobar:c: foobar_c!!merge <<: *foothing: foobar_thing
then
yq eval '.foobar | [..]' sample.yml
will output
- c: foobar_c!!merge <<: *foothing: foobar_thing- foobar_c- *foo- foobar_thing