Skip to content
Discussion options

You must be logged in to vote

You're on the right track with that, but first you have to tell it to recurse though the whole structure. So you will need to do somthing like:

yq e '.. | select(tag == "!!map") | with_entries(select(.key | match("x-.*")))' examples/data1.yaml

Explanation:

  1. .. tells yq to recursively match all the nodes
  2. select(tag == "!!map") we only select maps (as arrays wont have x- keys anyway
  3. with_entries(select(.key | match("x-.*"))) we filter out the maps to only include the keys that start with x-

Replies: 1 comment 11 replies

Comment options

You must be logged in to vote
11 replies
@steve-nay-sage
Comment options

@mikefarah
Comment options

@steve-nay-sage
Comment options

@mikefarah
Comment options

@steve-nay-sage
Comment options

Answer selected by mikefarah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants