Given arrays X and Y (preferably both as inputs, but otherwise, with one as input and the other hardcoded), how can I use jq to output the array containing all elements common to both? e.g. what is a value of f such that
echo '[1,2,3,4]' | jq 'f([2,4,6,8,10])'would output
[2,4]?
I've tried the following:
map(select(in([2,4,6,8,10]))) --> outputs [1,2,3,4]select(map(in([2,4,6,8,10]))) --> outputs [1,2,3,4,5]