【发布时间】:2016-02-19 11:13:10
【问题描述】:
我有一个如下所示的文件:
----------------------------------------------------------
Record : 1
SomeValue : foo1
SomeOtherValue : bar1
NthValue : 1234
----------------------------------------------------------
Record : 2
SomeValue : foo2
SomeOtherValue : bar2
NthValue : 2234
----------------------------------------------------------
Record : 1
SomeValue : foo3
SomeOtherValue : bar3
NthValue : 3234
我想转换它,使每条记录(由破折号字符串分隔)都在自己的行上,因此:
Record : 1 SomeValue : foo1 SomeOtherValue : bar1 NthValue : 1234
Record : 2 SomeValue : foo2 SomeOtherValue : bar2 NthValue : 4321
Record : 1 SomeValue : foo3 SomeOtherValue : bar3 NthValue : 0000
我一辈子都无法在不借助脚本的情况下通过简单的命令来解决问题。在这里的任何帮助将不胜感激。
顺便说一句,分隔符字符串始终相同,但每条记录中字段的数量和大小可能会有所不同。
【问题讨论】: