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

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

    You can use awk like this to combine ever 2 pair of lines:

    awk '{ if (NR%2 != 0) line=$0; else {printf("%s %s\n", line, $0); line="";} } \
         END {if (length(line)) print line;}' flle
    

提交回复
热议问题