2015-04-27 76 views
0

模式我已經有像每行日誌條目的文件:使用SED來分隔流

vert.x-worker-thread-5:606-5 [28281755664384/companyOfflineCaEnricherRSS] [oiq.contentdigestion.PipelineProcessorLink] - CertainClassifierPipelineProcessorInternal COMPLETE [75ms]: http://www.cadc.uscourts.gov/recordings/recordings.nsf/uscadcoralarguments.xml 
vert.x-worker-thread-6:524-7 [28281755664384/companyWebAndEventWorkerMultiPass][oiq.contentdigestion.PipelineProcessorLink] - CertainClassifierPipelineProcessorInternal COMPLETE [54ms]: http://a1851.g.akamaitech.net/f/1851/2996/24h/cache.xerox.com/downloads/usa/en/c/CEO_Commitment.pdf 

可以在任何一個可以幫助我在得到sed命令有下列模式

在加工線
companyOfflineCaEnricherRSS : CertainClassifierPipelineProcessorInternal 75 
companyWebAndEventWorkerMultiPass : CertainClassifierPipelineProcessorInternal 54 
+0

能否請您先秀一下自己的嘗試? –

+0

你能格式化你的輸入來清楚地顯示換行符嗎? – Dinesh

回答

1

使用此sed命令,讓你期望的輸出,

sed -r 's/[^\/]+.([^]]+).*- ([^ ]+)[^[]+.([^a-z]+).*/\1 : \2 \3/' FileName 

-r, --regexp-extended 

      use extended regular expressions in the script. 

Ø本安輸出:

companyOfflineCaEnricherRSS:CertainClassifierPipelineProcessorInternal 75個 companyWebAndEventWorkerMultiPass:CertainClassifierPipelineProcessorInternal 54

+0

它的工作。謝謝! – user2862093

+0

非常歡迎:) - – Kalanidhi