When using jq in streaming mode (because 100 GB file) it eats the first element. How can I avoid that?
echo [{"id":482,"a":"2","b":1},{"id":483,"a":"3","b":2}] | jq -c --stream "fromstream(1|truncate_stream(inputs))"
Output is
{"a":"2","b":1}
{"id":483,"a":"3","b":2}
The first element (id) is missing from the first array element.
This is jq version 1.6. It is on Windows 2010, but the same behaviour is also on jq 1.6 on Ubuntu 22.04.
Thanks
2
Answers
It seems that’s because you’re using
inputs
with--stream
.Using
.
seems better, but I’m not sure what you’re after:Use the
--null-input
(or-n
) flag. That way the standard input is set tonull
, andinputs
can fetch all actual inputs.