mirror of
https://github.com/mikefarah/yq.git
synced 2025-02-04 21:44:17 +00:00
Better formatting of merge arrays example
This commit is contained in:
parent
418bd1a806
commit
f5f148cadb
@ -262,8 +262,9 @@ And another sample another.yml file of:
|
|||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
yq eval-all '((.[] | {.a: .}) as $item ireduce ({}; . * $item )) as $uniqueMap
|
yq eval-all '
|
||||||
| ( $uniqueMap | to_entries | .[]) as $item ireduce([]; . + $item.value)
|
((.[] | {.a: .}) as $item ireduce ({}; . * $item )) as $uniqueMap
|
||||||
|
| ( $uniqueMap | to_entries | .[]) as $item ireduce([]; . + $item.value)
|
||||||
' sample.yml another.yml
|
' sample.yml another.yml
|
||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
|
@ -37,8 +37,9 @@ To use this, you will need to update '.[]' to be the expression to your array (e
|
|||||||
Thanks Kev from [stackoverflow](https://stackoverflow.com/a/70109529/1168223)
|
Thanks Kev from [stackoverflow](https://stackoverflow.com/a/70109529/1168223)
|
||||||
`
|
`
|
||||||
|
|
||||||
var mergeExpression = `((.[] | {.a: .}) as $item ireduce ({}; . * $item )) as $uniqueMap
|
var mergeExpression = `
|
||||||
| ( $uniqueMap | to_entries | .[]) as $item ireduce([]; . + $item.value)
|
((.[] | {.a: .}) as $item ireduce ({}; . * $item )) as $uniqueMap
|
||||||
|
| ( $uniqueMap | to_entries | .[]) as $item ireduce([]; . + $item.value)
|
||||||
`
|
`
|
||||||
|
|
||||||
var docWithHeader = `# here
|
var docWithHeader = `# here
|
||||||
|
Loading…
Reference in New Issue
Block a user