mirror of
https://github.com/mikefarah/yq.git
synced 2025-02-10 19:08:57 +00:00
543 B
543 B
Select is used to filter arrays and maps by a boolean expression.
Select elements from array
Given a sample.yml file of:
- cat
- goat
- dog
then
yq eval '.[] | select(. == "*at")' sample.yml
will output
cat
goat
Select and update matching values in map
Given a sample.yml file of:
a: {things: cat, bob: goat, horse: dog}
'': null
then
yq eval '(.a.[] | select(. == "*at")) |= "rabbit"' sample.yml
will output
a: {things: rabbit, bob: rabbit, horse: dog}
'': null