mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-23 22:25:42 +00:00
v4.44.5
This commit is contained in:
parent
57e4639631
commit
19118c5552
@ -37,6 +37,25 @@ fruit: banana
|
||||
name: sam
|
||||
```
|
||||
|
||||
## Get parent attribute
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
a:
|
||||
fruit: apple
|
||||
name: bob
|
||||
b:
|
||||
fruit: banana
|
||||
name: sam
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq '.. | select(. == "banana") | parent.name' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
sam
|
||||
```
|
||||
|
||||
## N-th parent
|
||||
You can optionally supply the number of levels to go up for the parent, the default being 1.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user