From 8c2488d25f8bf0cbade9b156dde349e86f5b38f5 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 29 Aug 2022 10:58:08 +1000 Subject: [PATCH] improved v3 merge docs --- upgrading-from-v3.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/upgrading-from-v3.md b/upgrading-from-v3.md index 364b8300..1b752e6f 100644 --- a/upgrading-from-v3.md +++ b/upgrading-from-v3.md @@ -118,10 +118,12 @@ yq 'del(.a.b.c)' sample.yaml ### Merging documents -Like `jq`, merge is done via the multiply operator. +Like `jq`, merge is done via the multiply operator. In yq, the merge operator can take extra options to modify how it works. + +For `v3` compatability, use the `n` option to only merge in new fields. ```bash -yq '. * load("file2.yaml")' file1.yaml +yq '. *n load("file2.yaml")' file1.yaml ``` See the [multiply documentation](https://mikefarah.gitbook.io/yq/operators/multiply-merge) for more example and options.