2015-07-13 33 views
0

我想grep日誌異常,並確定他們的罪名如何在列的基礎用grep唯一重複的記錄與數在solaris

以下獨特的樣品輸入

[msisdn:123][trxId:1234] | subscriptions | java.lang.Exception: this msidn NOT found 
[msisdn:432][trxId:1212] | subscriptions | java.lang.Exception: this msidn NOT found 
[msisdn:232][trxId:3232] | subscriptions | java.lang.Exception: this msidn NOT found 

我用以下,並示出了具有計數重複

grep -i exception my.log| cut -d'|' -f2- | uniq –c 

其示出了結果如預期,但我鬆散包含MSISDN和trxid第一部分,然後我用以下

grep -i exception my.log | sort -u -k 2,3 -t'|' 

它示出了具有采樣線和在其上載MSISDNtrxid我可以排除該採樣線的基唯一結果。

現在我怎麼能得到我最後一個使用的命令?

+0

編輯你的問題,以顯示預期的輸出考慮到樣品的輸入,我不知道,如果你想找到每計數msisdn或per trxid或兩者或其他的組合。無論如何,用一個小的,清晰的awk腳本將是絕對微不足道的。 –

回答

0

這應該工作:

grep -i exception my.log | sort -k 2,3 -t'|' | uniq -c -f 1 

輸出:

 3 [msisdn:123][trxId:1234] | subscriptions | java.lang.Exception: this msidn NOT found 
相關問題