Hi,
If I understand the doc correctly, I should be able to search the following array for an app called app2
apps:
- name: app1
slackChannel: my-team
- name: app2
autoSync: true
But the following doesn't work: yq read myfile.yaml "apps[*](.name==app2)".
Am I missing something?
I am using the the docker image for mikefarah/yq:3.3.2
@yfried : I guess the [*] will match all the array elements of the parent. I think you need to use the Search by children nodes feature to get the index of the element containing your required string app2 i.e. as
yq read myfile.yaml 'apps.(name==app2)'
Hi @inianv this doesn't work. I'm getting empty output. Any other ideas?
@inianv's solution is correct, and it works for me...
Most helpful comment
@yfried : I guess the
[*]will match all the array elements of the parent. I think you need to use the Search by children nodes feature to get the index of the element containing your required stringapp2i.e. as