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

后端 未结 21 2045
没有蜡笔的小新
没有蜡笔的小新 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:34

    Alternative to sed, awk, grep:

    xargs -n2 -d'\n'
    

    This is best when you want to join N lines and you only need space delimited output.

    My original answer was xargs -n2 which separates on words rather than lines. -d can be used to split the input by any single character.

提交回复
热议问题