I can combine 2 json files using jq, thus:
jq -s '.[0] * .[1]' file1.json file2.json >merged.json
I can combine an arbitrary number of json files by using a loop and on the second and subsequent iterations, used the output of the previous operation as one of the inputs. And with process substitution, that can be done via a pipe:
jq -s '.[0] * .[1]' file1.json file2.json | \ jq -s '.[0] * .[1]'<(cat) file3.json | \ jq -s '.[0] * .[1]'<(cat) file4.json ...
But how can I script merging of an arbitrary number of files without writing intermediate versions?
(I imagine that with a VERY large number of files I will have issues with ulimits / file handles - I am not concerned about that yet).