mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
30 lines
321 B
Markdown
30 lines
321 B
Markdown
|
|
||
|
## Get anchor
|
||
|
Given a sample.yml file of:
|
||
|
```yaml
|
||
|
a: &billyBob cat
|
||
|
```
|
||
|
then
|
||
|
```bash
|
||
|
yq eval '.a | anchor' sample.yml
|
||
|
```
|
||
|
will output
|
||
|
```yaml
|
||
|
billyBob
|
||
|
```
|
||
|
|
||
|
## Set anchor name
|
||
|
Given a sample.yml file of:
|
||
|
```yaml
|
||
|
a: cat
|
||
|
```
|
||
|
then
|
||
|
```bash
|
||
|
yq eval '.a anchor = "foobar"' sample.yml
|
||
|
```
|
||
|
will output
|
||
|
```yaml
|
||
|
a: &foobar cat
|
||
|
```
|
||
|
|