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

后端 未结 21 2047
没有蜡笔的小新
没有蜡笔的小新 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条回答
  •  旧时难觅i
    2020-11-22 15:24

    There are more ways to kill a dog than hanging. [1]

    awk '{key=$0; getline; print key ", " $0;}'
    

    Put whatever delimiter you like inside the quotes.


    References:

    1. Originally "Plenty of ways to skin the cat", reverted to an older, potentially originating expression that also has nothing to do with pets.

提交回复
热议问题