我在单行中有以下数据。
输入
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
你能帮我吗?感谢。
答案 0 :(得分:1)
您可以试试sed
:
sed 's/,\(pid:[0-9]* received at\)/\n\1/g' yourfile