Replies: 2 comments
-
Follow-up.
I'd like to avoid hard-coding the sub-objects, if possible (in case other environments are added). Or, at least, use a regex to match the sub-objects to exclude. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm on the road so I can't give the exact answer, you will need to use the "pick" operator. Check out the user guide for examples :)
…________________________________
From: glsutter ***@***.***>
Sent: Wednesday, September 21, 2022 4:01:32 AM
To: mikefarah/yq ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [mikefarah/yq] Exclude All Sub-Objects (Discussion #1350)
Follow-up.
One brute force approach that seems to work:
yq '.MAC | del(.PROD) | del(.TEST) | del(.STAGE)' variables.yml
location: useast
loc: usea
cidr: 10.1.0.0/26
I'd like to avoid hard-coding the sub-objects, if possible (in case other environments are added). Or, at least, use a regex to match the sub-objects to exclude.
—
Reply to this email directly, view it on GitHub<#1350 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAIZHNLRJNZOOT42ANQJPHLV7IJZZANCNFSM6AAAAAAQRG5KTA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a file that contains:
And I would like to retrieve the top-level MAC or MAG attributes without any of the sub-objects. For example, given input of MAC, I would like to get this output:
Of course, I can get everything under MAC by using
yq '.MAC'
but how do I exclude all of the sub-object data? FYI - I am willing to hard-code the sub-object identifiers PROD, STAGE, and TEST, if that's necessary.
I've tried it using del, and also del and select with a regex, but I can't seem to get the right syntax.
What's the best way to output only the top-level MAC or MAG properties without anything at lower levels in the hierarchy?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions