mirror of
https://github.com/mikefarah/yq.git
synced 2026-08-24 08:22:13 +08:00
Added parents operator
This commit is contained in:
@@ -56,6 +56,29 @@ will output
|
||||
sam
|
||||
```
|
||||
|
||||
## Get parents
|
||||
Match all parents
|
||||
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
a:
|
||||
b:
|
||||
c: cat
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq '.a.b.c | parents' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
- c: cat
|
||||
- b:
|
||||
c: cat
|
||||
- a:
|
||||
b:
|
||||
c: cat
|
||||
```
|
||||
|
||||
## N-th parent
|
||||
You can optionally supply the number of levels to go up for the parent, the default being 1.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user