From d27fb0ec78008188e6db30244e45bc96e77b0da3 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 16 Mar 2022 10:04:13 +1100 Subject: [PATCH] Update multiply docs --- pkg/yqlib/doc/operators/headers/multiply-merge.md | 11 +++++++++-- pkg/yqlib/doc/operators/multiply-merge.md | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pkg/yqlib/doc/operators/headers/multiply-merge.md b/pkg/yqlib/doc/operators/headers/multiply-merge.md index a2e69df1..5ae05279 100644 --- a/pkg/yqlib/doc/operators/headers/multiply-merge.md +++ b/pkg/yqlib/doc/operators/headers/multiply-merge.md @@ -15,9 +15,16 @@ You can control how objects are merged by using one or more of the following fla - `?` only merge _existing_ fields - `n` only merge _new_ fields -### Merging files + +### Merge two files together +This uses the load operator to merge file2 into file1. +```bash +yq '. *= load("file2.yml")' file1.yml +``` + +### Merging all files Note the use of `eval-all` to ensure all documents are loaded into memory. ```bash -yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' file1.yaml file2.yaml +yq eval-all '. as $item ireduce ({}; . * $item )' *.yml ``` diff --git a/pkg/yqlib/doc/operators/multiply-merge.md b/pkg/yqlib/doc/operators/multiply-merge.md index 20bbd968..f2a3fb52 100644 --- a/pkg/yqlib/doc/operators/multiply-merge.md +++ b/pkg/yqlib/doc/operators/multiply-merge.md @@ -15,11 +15,18 @@ You can control how objects are merged by using one or more of the following fla - `?` only merge _existing_ fields - `n` only merge _new_ fields -### Merging files + +### Merge two files together +This uses the load operator to merge file2 into file1. +```bash +yq '. *= load("file2.yml")' file1.yml +``` + +### Merging all files Note the use of `eval-all` to ensure all documents are loaded into memory. ```bash -yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' file1.yaml file2.yaml +yq eval-all '. as $item ireduce ({}; . * $item )' *.yml ``` {% hint style="warning" %}