How to merge every two lines into one from the command line?

后端 未结 21 2165
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 15:14

I have a text file with the following format. The first line is the \"KEY\" and the second line is the \"VALUE\".

KEY 4048:1736 string
3
KEY 0:1772 string
1         


        
21条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 15:30

    Another approach using vim would be:

    :g/KEY/join
    

    This applies a join (to the line below it) to all lines that have the word KEY in it. Result:

    KEY 4048:1736 string 3
    KEY 0:1772 string 1
    KEY 4192:1349 string 1
    KEY 7329:2407 string 2
    KEY 0:1774 string 1
    

提交回复
热议问题