From 2926e1d9b1a7fb2c74c8be00d03492a19028645a Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Thu, 10 Nov 2022 10:22:22 +1100 Subject: [PATCH] Improved set path example --- operators/path.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/operators/path.md b/operators/path.md index 2ac89c16..34c7c667 100644 --- a/operators/path.md +++ b/operators/path.md @@ -123,7 +123,7 @@ a: ``` ## Set path to extract prune deep paths -Like pick but recursive. +Like pick but recursive. This uses `ireduce` to deeply set the selected paths into an empty object, Given a sample.yml file of: ```yaml @@ -137,7 +137,8 @@ parentC: ``` then ```bash -yq '(.parentB.child2, .parentC.child1) as $i ireduce({}; setpath($i | path; $i))' sample.yml +yq '(.parentB.child2, .parentC.child1) as $i + ireduce({}; setpath($i | path; $i))' sample.yml ``` will output ```yaml