Open
Description
Please describe your feature request.
Inverse operator of contains
, probably called in
or something alike?
Describe the solution you'd like
If we have data1.yml like:
(please keep to around 10 lines )
- {item: 'Pizza', type: 'Food'}
- {item: 'Pasta', type: 'Food'}
- {item: 'Rose', type: 'Flower'}
- {item: 'Tulip', type: 'Flower'}
- {item: 'Hammer', type: 'Tool'}
- {item: 'Screwdriver', type: 'Tool'}
And we run a command:
yq 'filter(.type | in(["Tool", "Food"]))' data1.yml
it could output
- {item: 'Pizza', type: 'Food'}
- {item: 'Pasta', type: 'Food'}
- {item: 'Hammer', type: 'Tool'}
- {item: 'Screwdriver', type: 'Tool'}
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
yq 'filter(.type as $el | ["Tool", "Food"] | contains([$el]))' data1.yml
Additional context
jq
also has the in
operator