-3
我在單行中有以下數據。根據unix中的模式將單行分割爲多行
輸入
pid:1230 received at date 12/1/15 17:00:00:230,message ID:1200,Field1:anil,Field3:kumar,Field4:nitin,Field5:Rajat,Field6:Yogesh,Field7:Kishore,Field8:satya,pid:1230 sent message at date 12/1/15 17:00:00:232,message ID:1200,name1:anil,name3:kumar,name4:nitin,name5:Rajat,name6:Yogesh,name7:Kishore,name8:satya,pid:1230 Received message at date 12/1/15 17:00:00:232,message ID:1200,nkd1:anil,nkd3:kumar,nkd4:nitin,nkd5:Rajat,nkd6:Yogesh,nkd7:Kishore,nkd8:satya,pid:1230 sent at date 12/1/15 17:00:00:232,message ID:1200,Field1:anil,Field3:kumar,Field4:nitin,Field5:Rajat,Field6:Yogesh,Field7:Kishore,Field8:satya,pid:1230 received at date 12/1/15 17:00:00:230,message ID:1200,Field1:anil,Field3:kumar,Field4:nitin,Field5:Rajat,Field6:Yogesh,Field7:Kishore,Field8:satya,pid:1230 sent message at date 12/1/15 17:00:00:232,message ID:1200,name1:anil,name3:kumar,name4:nitin,name5:Rajat,name6:Yogesh,name7:Kishore,name8:satya,pid:1230 Received message at date 12/1/15 17:00:00:232,message ID:1200,nkd1:anil,nkd3:kumar,nkd4:nitin,nkd5:Rajat,nkd6:Yogesh,nkd7:Kishore,nkd8:satya,pid:1230 sent at date 12/1/15 17:00:00:232,message ID:1200,Field1:anil,Field3:kumar,Field4:nitin,Field5:Rajat,Field6:Yogesh,Field7:Kishore,Field8:satya
我要打破單一線多條線路。如果該字段包含「收到」,那麼我想分割成一個換行符。單行以上可以分成2行。
預期輸出:
pid:1230 received at date 12/1/15 17:00:00:230,message ID:1200,Field1:anil,Field3:kumar,Field4:nitin,Field5:Rajat,Field6:Yogesh,Field7:Kishore,Field8:satya,pid:1230 sent message at date 12/1/15 17:00:00:232,message ID:1200,name1:anil,name3:kumar,name4:nitin,name5:Rajat,name6:Yogesh,name7:Kishore,name8:satya,pid:1230 Received message at date 12/1/15 17:00:00:232,message ID:1200,nkd1:anil,nkd3:kumar,nkd4:nitin,nkd5:Rajat,nkd6:Yogesh,nkd7:Kishore,nkd8:satya,pid:1230 sent at date 12/1/15 17:00:00:232,message ID:1200,Field1:anil,Field3:kumar,Field4:nitin,Field5:Rajat,Field6:Yogesh,Field7:Kishore,Field8:satya
pid:1230 received at date 12/1/15 17:00:00:230,message ID:1200,Field1:anil,Field3:kumar,Field4:nitin,Field5:Rajat,Field6:Yogesh,Field7:Kishore,Field8:satya,pid:1230 sent message at date 12/1/15 17:00:00:232,message ID:1200,name1:anil,name3:kumar,name4:nitin,name5:Rajat,name6:Yogesh,name7:Kishore,name8:satya,pid:1230 Received message at date 12/1/15 17:00:00:232,message ID:1200,nkd1:anil,nkd3:kumar,nkd4:nitin,nkd5:Rajat,nkd6:Yogesh,nkd7:Kishore,nkd8:satya,pid:1230 sent at date 12/1/15 17:00:00:232,message ID:1200,Field1:anil,Field3:kumar,Field4:nitin,Field5:Rajat,Field6:Yogesh,Field7:Kishore,Field8:satya
能否請你幫我。謝謝。
它看起來像你真正想做的,是的'PID每次發生前插入一個換行符:'。 –
不是每一次出現的PID,我想插入新行,當PID有「收到」字符串。 –
請[編輯]您的問題向我們展示一個最小的例子,其中包含您的輸入數據的代表性樣本。刪除一些字段以縮短每行,並向我們展示一些換行符不應插入(如果有的話)以及應該在哪裏的地方的示例。 –