I have this yaml structure:
animals:
- cat
- dog
- rat
I want to uise yq to find out, if there is a specific animal (i.e. cat)
I expected something like this:
yq read file.yaml 'animals==cat'
but this does not work. is there any way to find out, if there is a arrayelement named "cat" (and print cat or nothing when not found)
Not at the moment :(
the find array by element currently only works for arrays of maps. Need to come up with syntax for finding an element in an array of scalars.
perhaps:
yq r file.yaml 'animals(*==cat)'
It will be a big improvement !!
the ability to select an item is really powerful, like select and pipe in jq
Fixed in https://github.com/mikefarah/yq/releases/tag/3.2.0
See https://mikefarah.gitbook.io/yq/usage/path-expressions#matching-children-values
Note that I used a '.' instead of '*' as wildcards already mean something :)
yq r file.yaml 'animals(.==cat)'
Ok Thanks ;o)
Most helpful comment
Not at the moment :(
the find array by element currently only works for arrays of maps. Need to come up with syntax for finding an element in an array of scalars.
perhaps: