Concatenating every other line with the next

后端 未结 5 1221
醉话见心
醉话见心 2020-12-14 15:11

In a text document I want to concatenate every other line with the next. I guess sed is the thing to use? How would this be done?

5条回答
  •  无人及你
    2020-12-14 15:40

    Simple awk solution:

    awk '{getline b;printf("%s %s\n",$0,b)}' file
    

    Test:

    [jaypal:~/Temp] seq 11 > file
    [jaypal:~/Temp] awk '{getline b;printf("%s %s\n",$0,b)}' file
    1 2
    3 4
    5 6
    7 8
    9 10
    11 
    

提交回复
热议问题