-1
我有了日誌條目,如文件:結合2個工作GREP表達式爲一個
格式1:
INFO 07 May 2015 15:24:35,146 vert.x-worker-thread-19:40422-6 [28782710226944/personWebApiMultiPass:UnfilteredNamedEntityPipelineProcessor:unfilteredNamedEntityPipelineProcessor] [oiq.contentdigestion.PipelineProcessor] - COMPLETE >10000ms [16992ms]: http://example1.com/long-url/etc.html
格式2:
INFO 07 May 2015 15:24:34,648 vert.x-worker-thread-12:40464-2 [28782710226945/personWebApiMultiPass:HighlyAssociatedEntitiesPipelineProcessorInternal] [oiq.contentdigestion.PipelineProcessor] - COMPLETE [0 ms]: http://example2.com/yet-another-long-url/etc.html
注:beteween的區別2行是方括號[]
內的時間格式。
要匹配的格式1行,我用下面的grep命令:
grep -E "\[[0-9]* ms\]" filename
爲2行相匹配的格式,我用下面的grep命令:
grep -E "\[[0-9]*ms\]" filename
任何人都可以有幫助grep表達式匹配兩個格式行?
grep'\ [[0-9] \ {1,\} * ms \]'文件工作。謝謝! – user2862093
@ user2862093像我在回答中所做的那樣,您應該轉義外部的''['和'\]'',否則正則表達式的含義會發生變化。 –