我有一個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進行輸入時,如果沒有不可並行的初始讀取通道,則無法進行這種優化,因爲輸入流只能從前到後只讀取一次。 –