Last updated
Was this helpful?
Last updated
Was this helpful?
As a general rule, you should wrap paths in quotes to prevent your CLI from processing *
, []
and other special characters.
'a.b.c'
'a.b[1].c'
(e.g. when using the write command)
'a.b[+].c'
Will add a new entry:
Negative array indexes can be used to traverse the array in reverse
'a.b[-1].c'
Will access the last element in the b
array and yield:
'a.*.c'
'bob.item*.cats'
'a.b[*].c'
**
will match arbitrary nodes for both maps and arrays:
'a.**.c'
You can search children by nodes - note that this will return the parent of the matching expression, in the example below the parent(s) will be the matching indices of the 'a' array. We can then navigate down to get 'b.c' of each matching indice.
'a.(b.d==cat).b.c'
'a.(b.d==cat*).c'
'animals(.==cat)'
this also works in maps, and with prefixes
'animals(.==c*)'
When your yaml field has special characters that overlap with yq
path expression characters, you will need to escape them in order for the command to work.
When specifying a key that has a dot use key lookup indicator.
Any valid yaml key can be specified as part of a key lookup.
Note that the path is in single quotes to avoid the double quotes being interpreted by your shell.
The flag terminator needs to be used to stop the app from attempting to parse the subsequent arguments as flags, if they start if a dash.
Will result in
Path expressions are used to deeply navigate and match particular yaml nodes.