Closed. This question needs details or clarity。它当前不接受答案。
想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
4年前关闭。
我单行有以下数据。
输入值
我想将单行分成多行。如果该字段包含“接收于”,那么我想拆分为换行符。上面的单行可以分为2行。
预期产量:
你能帮我么。谢谢。
想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
4年前关闭。
我单行有以下数据。
输入值
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
你能帮我么。谢谢。
最佳答案
您可以尝试以下sed
:
sed 's/,\(pid:[0-9]* received at\)/\n\1/g' yourfile
关于linux - 根据UNIX中的模式将单行拆分为多行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34311509/
10-13 09:36