我有一个JSON对象的流文件如下:猛砸有JQ分组
{"id":4496,"status":"Analyze","severity":"Critical","severityCode":1,"state":"New","code":"RNPD.DEREF","title":"Suspicious dereference of pointer before NULL check","message":"Suspicious dereference of pointer \u0027peer-\u003esctSapCb\u0027 before NULL check at line 516","file":"/home/build/branches/mmm/file1","method":"CzUiCztGpReq","owner":"unowned","taxonomyName":"C and C++","dateOriginated":1473991086512,"url":"http://xxx/yyy","issueIds":[4494]}
{"id":4497,"status":"Analyze","severity":"Critical","severityCode":1,"state":"New","code":"NPD.GEN.CALL.MIGHT","title":"Null pointer may be passed to function that may dereference it","message":"Null pointer \u0027tmpEncodedPdu\u0027 that comes from line 346 may be passed to function and can be dereferenced there by passing argument 1 to function \u0027SCpyMsgMsgF\u0027 at line 537.","file":"/home/build/branches/mmm/file1","method":"CzUiCztGpReq","owner":"unowned","taxonomyName":"C and C++","dateOriginated":1473991086512,"url":"http://xxx/yyy/zzz","issueIds":[4495]}
{"id":4498,"status":"Analyze","severity":"Critical","severityCode":1,"state":"New","code":"NPD.GEN.CALL.MIGHT","title":"Null pointer may be passed to function that may dereference it","message":"Null pointer \u0027tmpEncodedPdu\u0027 that comes from line 346 may be passed to function and can be dereferenced there by passing argument 1 to function \u0027SCpyMsgMsgF\u0027 at line 537.","file":"/home/build/branches/mmm/otherfile.c","method":"CzUiCztGpReq","owner":"unowned","taxonomyName":"C and C++","dateOriginated":1473991086512,"url":"http://xxx/yyy/zzz","issueIds":[4495]}
我想与JQ获得(或其他方式),三行,每一个的ID ,网址和文件名:
这是我到目前为止有:
cat /tmp/file.json | ~/bin_compciv/jq --raw-output '.id,.url,.file'
结果:
4496
http://xxx/yyy
/home/build/branches/mmm/file1
.
.
.
但 - 我想将它们分组按文件名,这样我会得到URL和ID的逗号分隔列表放在同一行,像这样:
4496,4497
http://xxx/yyy,http://xxx/yyy/zzz
/home/build/branches/mmm/file1
更好运行'jq ...
这对于'jq'来说并不重要,但是对sort分类很重要 - 如果它有一个真正的文件句柄,那么'sort'的优化实现可以使子进程寻求不同的部分文件,并行排序组件,然后在父进程中进行合并排序;使用不可寻址的FIFO进行输入时,如果没有不可并行的初始读取通道,则无法进行这种优化,因为输入流只能从前到后只读取一次。 –