yq/pkg/yqlib/doc/operators/headers/path.md

9 lines
500 B
Markdown
Raw Normal View History

2021-11-03 04:00:58 +00:00
# Path
2022-10-05 09:09:53 +00:00
The `path` operator can be used to get the traversal paths of matching nodes in an expression. The path is returned as an array, which if traversed in order will lead to the matching node.
2020-11-26 00:20:53 +00:00
You can get the key/index of matching nodes by using the `path` operator to return the path array then piping that through `.[-1]` to get the last element of that array, the key.
2022-10-05 09:09:53 +00:00
Use `setpath` to set a value to the path array returned by `path`, and similarly `delpaths` for an array of path arrays.