jq: selecting a subset of keys from an object
solution with inside check: jq ‘with_entries(select([.key] | inside([“key1”, “key2”])))’
solution with inside check: jq ‘with_entries(select([.key] | inside([“key1”, “key2”])))’
Recursion is your friend for this task. For each element – “guess” if it is in the current subset, and recursively invoke with the guess and a smaller superset you can select from. Doing so for both the “yes” and “no” guesses – will result in all possible subsets. Restraining yourself to a certain length … Read more
Suppose a = [‘a’, ‘b’, ‘c’, 3, 4, ‘d’, 6, 7, 8] and the list of indexes is stored in b= [0, 1, 2, 4, 6, 7, 8] then a simple one-line solution will be c = [a[i] for i in b]