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

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

    awk:

    awk 'NR%2{printf "%s ",$0;next;}1' yourFile
    

    note, there is an empty line at the end of output.

    sed:

    sed 'N;s/\n/ /' yourFile
    

提交回复
热议问题