Using Input Filename In JQ Pipeline
One other JQ thing: there’s an operator which returns the filename of the file currently being processed by JQ, called input_filename
.
This can be used alongside the concat operator to reproduce something similar to grep -H
:
$ jq -r 'input_filename + ": " + .payload.data' *.json
message-0000.json: id_111
message-0001.json: id_234
message-0002.json: id_512